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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
SEPA
Frequent Visitor

Calculate average by distinct dividend value for each category in POWER BI / DAX

Hi All,

I have a data like below and i want to calculate the average by distinct divident category.

Data:

MonthCountryStoreTHRSValue%pctn
APRSingaporeSG12005025.00
APRSingaporeSG12006030.00
APRSingaporeSG21002020.00

 


now i want to calculate the average by Store:

Expected result:

 Avg
SG127.50
SG220.00

 

The dax i tried:

 

measure1_mecaverage_by_str_monthly_trend =
CALCULATE (
AVERAGE ('Fact'[pctn]),
ALLEXCEPT ( 'Fact', 'Fact'[Month], Fact[Country],Fact[Store])
)
 
Can help to calculate average by using distinct divident value for each store

 

2 ACCEPTED SOLUTIONS
v-cgao-msft
Community Support
Community Support

Hi @SEPA ,

 

Using your measures will give you the results you expect.

vcgaomsft_0-1651111714042.png

vcgaomsft_1-1651111849124.png

Or am I not understanding your needs? If you want to use different measure for different stores, you can try using the SWITCH functions. For example.

Measure = 
SWITCH(
    TRUE(),
    MAX('Fact'[Store]) = "SG1",[measure1_mecaverage_by_str_monthly_trend],
    MAX('Fact'[Store]) = "SG2",[measure2_mecaverage_by_str_monthly_trend])

Then drag the measure and field [Store] into the table visual.

 

The pbix file is attached for reference.

 

Best Regards,
Community Support Team_Gao

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems with it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly -- How to provide sample data

View solution in original post

Dear @SEPA,

 

Please try using this measure.

Average of country = 
CALCULATE (
    AVERAGEX (
        VALUES ( 'Fact'[Store] ),
        [measure1_mecaverage_by_str_monthly_trend]
    ),
    ALL ( 'Fact' )
)

vcgaomsft_0-1651129556654.png

The pbix file is attached for reference.

 

Best Regards,
Community Support Team_Gao

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems with it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly -- How to provide sample data

View solution in original post

5 REPLIES 5
v-cgao-msft
Community Support
Community Support

Hi @SEPA ,

 

Using your measures will give you the results you expect.

vcgaomsft_0-1651111714042.png

vcgaomsft_1-1651111849124.png

Or am I not understanding your needs? If you want to use different measure for different stores, you can try using the SWITCH functions. For example.

Measure = 
SWITCH(
    TRUE(),
    MAX('Fact'[Store]) = "SG1",[measure1_mecaverage_by_str_monthly_trend],
    MAX('Fact'[Store]) = "SG2",[measure2_mecaverage_by_str_monthly_trend])

Then drag the measure and field [Store] into the table visual.

 

The pbix file is attached for reference.

 

Best Regards,
Community Support Team_Gao

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems with it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly -- How to provide sample data

Dear V-Cgao-msft,

Thanks for your response on this. And, yes the distinct average for store is comign fine, but however i am facing issue while calculating average for the calculated measure.

 

below is expected, 

monthcountrystorethrsvaluesAvergae of each recordAverage of StoreAverage of country
APRSingaporeSG12005025.0%27.50%23.75%
APRSingaporeSG12006030.0%
APRSingaporeSG21002020.0%20.00%
       this one is average of G

 

need to find out average of country from already calculated measure (average of store)

SEPA
Frequent Visitor

yes i was looking the above output

Dear @SEPA,

 

Please try using this measure.

Average of country = 
CALCULATE (
    AVERAGEX (
        VALUES ( 'Fact'[Store] ),
        [measure1_mecaverage_by_str_monthly_trend]
    ),
    ALL ( 'Fact' )
)

vcgaomsft_0-1651129556654.png

The pbix file is attached for reference.

 

Best Regards,
Community Support Team_Gao

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems with it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly -- How to provide sample data

Thank you, it works for me...

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.