Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
professional65
Frequent Visitor

sum of group of values

Dears,

I have a huge amount of data  but to summarize, I show them as bellow as an example: 

 

FieldWell Name User CodeDURATIONstart depthend depth
carilCRL1DRL11  
carilCRL1DRL10,515001800
CanelaCAN2BOP2  
CanelaCAN3BOP2nullnull
CanelaCAN4DRL1111001150
carilCRL2DRL1313001430
carilCRL3CMT11nullnull
CanelaCAN2CM12nullnull
CanelaCAN3BOP4nullnull
CanelaCAN3DRL1513001600
carilCRL1DRL16nullnull
carilCRL2DRL1522002400
carilCRL1DRL1718202150
carilCRL1DRL12300450
CanelaCAN2BOP3nullnull
CanelaCAN3BOP1nullnull
CanelaCAN2BOP2nullnull
CanelaCAN3BOP4nullnull
CanelaCAN3DRL1112001230
carilCRL1BOP3nullnull
carilCRL2CMT11nullnull
carilCRL1CMT15nullnull
carilCRL1BOP2  
carilCRL2DRL1 21502200
carilCRL1DRL1022002200
carilCRL1BOP1nullnull
carilCRL2CMT1 nullnull
carilCRL1DRL1null750900

 

I need to get average of duration for each distinct User Code for total project and then I can make a filter  (slicer) to filter based on Fields. But for that, I should also consider that for each well (in Well Name column), the real value related to each user code is sum of durations for a user code in same well. as follow

FieldWell Name User CodeDURATION
CanelaCAN2BOP7
CM12
CAN3BOP11
DRL16
CAN4DRL11
carilCRL1DRL116,5
BOP6
CMT15
CRL2DRL14
CMT11
CRL3CMT1

1

where Duration for BOP user Code for CAN-2 IS 2+3+2 = 7
I need to make an Average duration of each user code for each well. 
I make this formula but it does not give me the real result: 

Ave Total =
CALCULATE(
    AVERAGEX(
        SUMMARIZE(V_WVT_WVJOBTIMELOG, V_WVT_WVJOBTIMELOG[User Code], "Ave Total",
       AVERAGE(V_WVT_WVJOBTIMELOG[DurationPerHour])),
        [Ave Total]
    )
)


Also I need to determin a measure to calculate the (Interval =End Depth - Start Depth) / Duration, by adding a condtion that if the duration is 0, consider the result as a null value and if Duration = 0 consider it as blank!

Thanks and Regards

 

1 REPLY 1
v-junyant-msft
Community Support
Community Support

Hi @professional65 ,

To calculate an Average duration of each user code for each well, you can try to use this DAX to create a calculated column:

Average_Duration = 
CALCULATE(
    AVERAGE('Table'[DURATION]),
    ALLEXCEPT('Table', 'Table'[Well Name ], 'Table'[User Code])
)

And the final output is as below:

vjunyantmsft_0-1713233218655.png


And I quite can't understand what do you mean by "if the duration is 0, consider the result as a null value and if Duration = 0 consider it as blank!", don't the conditions before and after "and" mean the same thing? Or are duration and Duration two different things?
And I can give you an example to calculate the (Interval =End Depth - Start Depth) / Duration:

Interval = 
IF(
    [DURATION] = BLANK(),
    BLANK(),
    ([end depth] - [start depth]) / [DURATION]
)

The output is as below:

vjunyantmsft_1-1713233622860.png

 

Best Regards,
Dino Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Sept PBI Carousel

Power BI Monthly Update - September 2024

Check out the September 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

Find out what's new and trending in the Fabric Community.

Top Kudoed Authors