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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
hamzashafiq
Kudo Collector
Kudo Collector

Need average of usage for each serial number

Hi Folks,

 

I need your help to calculate Usage formula for each "Serial Number". The formula for Total Usage I have currently built is just subtracting the Max Hours Meter Reading with Minimum Hours Meter Reading. It works fine if the Model has only one Serial Number, however if the Model has multiple serial number (Please see the serial number column in Screenshot), I need to calculate the Max-Min for each Serial Number and then calculate the average to get "Total Usage". Currently the Total Usage is 693 (884-191) but it should be 119(884-765) and 16(207-191) and the average of 119 and 16 should be 67.5 (Average Usage).   Please see the attached screenshot for the data I have. Please see the blue highlighted columns.

 

hamzashafiq_0-1645790565678.png

 

1 ACCEPTED SOLUTION
johnt75
Super User
Super User

You need to summarize by serial number and then work out the average of the individual values, something like

Total Usage = AVERAGEX(
ADDCOLUMNS( SUMMARIZE( TableName[Serial Number] ),
"@usage", CALCULATE( MAX( TableName[Meter Hours]) - MIN( TableName[Meter Hours] ) )
),
[@usage]
)

 

View solution in original post

3 REPLIES 3
hamzashafiq
Kudo Collector
Kudo Collector

It's working, thank you!

hamzashafiq
Kudo Collector
Kudo Collector

It's giving me syntax error.

 

johnt75
Super User
Super User

You need to summarize by serial number and then work out the average of the individual values, something like

Total Usage = AVERAGEX(
ADDCOLUMNS( SUMMARIZE( TableName[Serial Number] ),
"@usage", CALCULATE( MAX( TableName[Meter Hours]) - MIN( TableName[Meter Hours] ) )
),
[@usage]
)

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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