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.
I'm trying to calculate the median of a Market Share measure by store size.
I've got Table 1 which has store names, store size (big or small), category (e.g. fruit, veg) and units sold.
I have a measure:
Market share sales = DIVIDE(SUM('Table1'[Units sold]),CALCULATE(SUM('Table1'[Units sold]),ALL('Table1'[Store Name],'Table1'[Store Size])))
Which calculates the market share for a particular store and/or category of food. When I filter for store size the market share remains the same (which it should).
I want to be able to calculate the median of the market share by store size.
I've got
Big Median Market Share =
CALCULATE(MEDIANX (
SUMMARIZE (
'Table1',
'Table1'[Store Name],
"MShare", DIVIDE(SUM('Table1'[Units sold]),CALCULATE(SUM('Table1'[Units sold]),ALL('Table1'[Store Name])))
),
[MShare]
),FILTER(Table1,Table1[Store Size]="Big"))
But this doesn't give me the right answer (too high). If I change the ALL to ALL('Table1'[Store Size] then I just get median market shares of 100%
Can anyone help? I suspect I'm doing dodgy things with the filters but I just can't work out how to fix it.
Thanks in advance!
Solved! Go to Solution.
Hi @Anonymous,
We can create a measure as below.
Measure = MEDIANX(VALUES(Sheet1[Store]),[Market Share Sales])
Regards,
Frank
Hi @Anonymous,
Did you try to use ALLEXCEPT or Values? Could you please share your pbix and excepted result to me? if you don't have confidential data? Please upload your file to One Drive and share the link here.
Regards,
Frank
Hi @v-frfei-msft and thanks for replying.
I've uploaded a pbix file here: https://1drv.ms/u/s!AjkKjlnY4o11hCa1KWzBV-0fIfwM
Median Market share (for Store type = Franchise) should be
2015 - 0.98%
2016 - 3.51%
2017 - 0.03%
I've tried ALLEXCEPT but not VALUE.
I think it's calculating the median without filtering for store type, but if I add Store Type to the Median Market share then they all come out at 100%.
Help very gratefully appreciated!
Hi @Anonymous,
We can create a measure as below.
Measure = MEDIANX(VALUES(Sheet1[Store]),[Market Share Sales])
Regards,
Frank
Thank you @v-frfei-msft that gives the correct answer!
I've modified it slightly to:
Measure = CALCULATE(MEDIANX(VALUES(Sheet1[Store]),[Market Share Sales]),Sheet1[Store Type]="Franchise")
So that it always shows the median for the Franchises (just adding it here so I remember for the future!).
Your help is greatly appreciated!
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
112 | |
99 | |
73 | |
72 | |
49 |
User | Count |
---|---|
145 | |
109 | |
109 | |
90 | |
64 |