John Brand Posted December 15, 2021 Share Posted December 15, 2021 I'm trying to calculate the average TVD once a wellbore hits 80 degrees inclinationall the way to total depth (maximum measured depth) for eachwell. In other words, calculate the average TVDfor the rows in bold textover each well ID. Measured Depth Inclination True Vertical Depth Well ID Measured Depth Inclination True Vertical Depth Well ID 2000 40 1600 A 3000 60 1800 A 4000 80 2000 A 5000 90 2100 A 6000 75 2200 A 7000 75 2400 A 1000 20 800 B 2000 40 1400 B 3000 60 1700 B 4000 80 2000 B 5000 90 2200 B 6000 78 2100 B Link to comment Share on other sites More sharing options...
Fabian Duerr Posted December 16, 2021 Share Posted December 16, 2021 Let's first check for each well if you reached at least 80. I do this by checking the max. value of all the previous rows. Only if this condition is met I calculate the avg. TVD per well. Otherwise it returns NULL. If(Max([inclination]) OVER Intersect([Well ID],AllPrevious([Measured Depth])) >= 80,Avg([True Vertical Depth]) OVER [Well ID]) PS:It's an advantage that your data table is already in the right order. Otherwise you would have to use a rank function to get it into the right order and to get the AllPrevious() work correctly. Link to comment Share on other sites More sharing options...
John Brand Posted December 28, 2021 Author Share Posted December 28, 2021 So my actual dataset is not sorted by Well ID & MD like my sample data is. I did calculate a new column ranking MD over Well ID. Where would this ranked MD column be incorporated into the expression that you provided Would I replace [Measured Depth] with [Ranked Measured Depth] Thank you. Link to comment Share on other sites More sharing options...
Fabian Duerr Posted December 29, 2021 Share Posted December 29, 2021 Sorry, my comment regarding the order/rank and AllPrevious() function was incorrect in this case. You don't have to worry about that. AllPrevious() will work fine with your [Measured Depth] column as you only drill down deeper (1000,2000,3000,...). Otherwise you would replace it with your anked column, yes. Link to comment Share on other sites More sharing options...
John Brand Posted December 29, 2021 Author Share Posted December 29, 2021 Thank you for your help! It worked beautifully. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now