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
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
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.

Top Solution Authors