cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
mizaskun
Helper I
Helper I

How to custom average a measure

Good afternoon,

 

I am working with the following model:

 

Values

REGIONVALUE
EUROPE8
EUROPE3
EUROPE4
ASIA1
ASIA2
ASIA6
AMERICA5
AMERICA7

 

Weights

REGIONWEIGHT
AMERICA7
ASIA2
EUROPE14

 

I need to subtotalize the values by region as a measure. Thus, after having inquired in the forum I got the following DAX expression:

 

AVRG = CALCULATE(
AVERAGE( 'VALUES'[VALUE] ),
VALUES( 'VALUES'[REGION] ),
ALLSELECTED( 'VALUES' )
)
 
Resulting on the following table: 
REGIONVALUEWEIGHTAVRG
AMERICA1276
ASIA923
EUROPE15145

 

If I delete the Region column everything sums up in a line with a 4,50 average value. What I need is to customize that average calculation by using the Weights table values and the filtered data in the report.

 

If I select AMERICA and ASIA, the result should be:

REGIONVALUEWEIGHTAVRGC_WEIGHTTOTAL
AMERICA127678%4,67
ASIA92322%0,67
 sum9 result5,33

 

If I select AMERICA, ASIA and EUROPE, the result should be:

REGIONVALUEWEIGHTAVRGC_WEIGHTTOTAL
AMERICA127630%1,83
ASIA9239%0,26
EUROPE1514561%3,04
 sum23 result5,13

 

This result should remain even if I delete columns from the table. If I just want to show the TOTAL column, the result value should be the same (5,33 and 5,13 depending on the report filters).

 

How could I achieve this? 

 

Thank you so much in advance,

1 ACCEPTED SOLUTION
Jihwan_Kim
Community Champion
Community Champion

Hi, @mizaskun 

Please check the below picture and the sample pbix file's link down below.

All measures are in the sample pbix file.

 

Picture2.png

 

https://www.dropbox.com/s/w38enf8sb5ysogt/mizaskun.pbix?dl=0 

 

Hi, My name is Jihwan Kim.

 

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

 

Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM


If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

Best regards, JiHwan Kim

Linkedin: https://www.linkedin.com/in/jihwankim1975/

Twitter: https://twitter.com/Jihwan_JHKIM

View solution in original post

2 REPLIES 2
Jihwan_Kim
Community Champion
Community Champion

Hi, @mizaskun 

Please check the below picture and the sample pbix file's link down below.

All measures are in the sample pbix file.

 

Picture2.png

 

https://www.dropbox.com/s/w38enf8sb5ysogt/mizaskun.pbix?dl=0 

 

Hi, My name is Jihwan Kim.

 

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

 

Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM


If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

Best regards, JiHwan Kim

Linkedin: https://www.linkedin.com/in/jihwankim1975/

Twitter: https://twitter.com/Jihwan_JHKIM

View solution in original post

Thank you so much @Jihwan_Kim !! This works fine! I will work on transferring the formula to my model.

Helpful resources

Announcements
MBAS on Demand

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

July 2021 Update 768x460.png

Check it out!

Click here to read more about the July 2021 Updates

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Urdu Hindi D365 Bootcamp 768x460.png

Urdu Hindi D365 Bootcamp

Dont miss our very own April Dunnam’s The Developer Guide to the Galaxy! Find out what the Power Platform has to offer for the traditional developer.

Top Solution Authors