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
Chillytouch
Frequent Visitor

Aggregate values differently based on measure/logic?

Hi,

 

I have a matrix that I created with example data shown below. I have been trying to get my data into a format like this for a while now however I am running into a road block with aggregation. The way the data source I made is, is I have a row per measure per fiscal period. so for instance I have a row that is fiscal period - 1 metric_type - revenue metric_value - 10000 and then records for salary and paypercentrev with the differetn metric_type values. So in the matrix in powerbi I put the metric_value in the "value" box and metric_type in the "columns" box above the year/period. However when I am drilling up/down by fiscal year/period it is summing all values naturally. However, for the "paypercentrev" values I don't want them summed, I want them averaged. Since it's the same column technically (metric_value), is this even possible? Is there any way to say, ok if column metric_type = "revenue" or "salary" then sum when you drill up/down but if metric_type = "paypercentrev" then average? Any advice would be appreciated. Thank you!

Untitled.png

1 ACCEPTED SOLUTION
v-rzhou-msft
Community Support
Community Support

Hi @Chillytouch ,

Do you want to show average if metric_type = "paypercentrev" , and show sum if metric_type = "revenue" or "salary"? I think you can try If function to achieve your goal.

My Sample:

1.png

Measure:

Measure = 
IF(MAX('Table'[metric_type])="paypercentrev",AVERAGE('Table'[Value]),SUM('Table'[Value]))

Result is as below.

2.png

Best Regards,
Rico Zhou

 

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

 

View solution in original post

2 REPLIES 2
v-rzhou-msft
Community Support
Community Support

Hi @Chillytouch ,

Do you want to show average if metric_type = "paypercentrev" , and show sum if metric_type = "revenue" or "salary"? I think you can try If function to achieve your goal.

My Sample:

1.png

Measure:

Measure = 
IF(MAX('Table'[metric_type])="paypercentrev",AVERAGE('Table'[Value]),SUM('Table'[Value]))

Result is as below.

2.png

Best Regards,
Rico Zhou

 

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

 

amitchandak
Super User
Super User

@Chillytouch , if you want to change the calculation based on level you can use isinscope

https://www.kasperonbi.com/use-isinscope-to-get-the-right-hierarchy-level-in-dax/

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.