cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Anonymous
Not applicable

Median of a filtered measure

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!

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support
Community Support

Re: Median of a filtered measure

Hi @Anonymous,

 

We can create a measure as below.

 

Measure = MEDIANX(VALUES(Sheet1[Store]),[Market Share Sales])

Capture.PNG

 

Regards,

Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

4 REPLIES 4
Community Support
Community Support

Re: Median of a filtered measure

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

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.
Anonymous
Not applicable

Re: Median of a filtered measure

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!

 

 

 

 

 

Community Support
Community Support

Re: Median of a filtered measure

Hi @Anonymous,

 

We can create a measure as below.

 

Measure = MEDIANX(VALUES(Sheet1[Store]),[Market Share Sales])

Capture.PNG

 

Regards,

Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

Anonymous
Not applicable

Re: Median of a filtered measure

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!

Helpful resources

Announcements
New Ranks Launched March 24th!

New Ranks Launched March 24th!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power BI Community!

‘Better Together’ Contest Finalists Announced!

‘Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

Arun 'Triple A' Event Video, Q&A, and Slides

Arun 'Triple A' Event Video, Q&A, and Slides

Missed the Arun 'Triple A' event or want to revisit it? We've got you covered! Check out the video, Q&A, and slides now.

Join THE global Microsoft Power Platform event series.

Join THE global Power Platform event series.

Attend for two days of expert-led learning and innovation on topics like AI and Analytics, powered by Dynamic Communities.

Community Summit North America

Community Summit North America

Innovate, Collaborate, Grow. The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors