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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
bharukc
Helper I
Helper I

Median of filtered values

How do I get the median of filtered values. 

YearPhasestudy_idnamecategory
2017Phase 1abcA1
2017Phase 1abA1
2017Phase ObcB1
2017Phase OabcdC1
2018Phase 1bcdA1
2018Phase ObeA2
2018Phase 1efB1
2018Phase OenC1
2018Phase 1zfB1

 

I want to calculate median of count of study_id by Year, Phase on name. Also take into account for the filter being used in the report of Category = 1

Result should be

YearPhaseMedian of count of study_id
2017Phase 11
1 ACCEPTED SOLUTION

I was able to solve it myself. 
medianx(values(count(name))), study_id))

View solution in original post

5 REPLIES 5
Icey
Community Support
Community Support

Hi @bharukc ,

 

I can't understand your scenario exactly, could you share me more details?

 

1. Like what @BeaBF mentioned, what's the meaning of "count of study_id by Year, Phase on name"? also by name?

 

2. Based on my understanding, the count for 2017 Phase is 2. Then how does the result "1" get?

Year Phase Median of count of study_id
2017 Phase 1 1

 

Could you explain the calculation logic?

 

 

Best Regards,

Icey

I was able to solve it myself. 
medianx(values(count(name))), study_id))

Icey
Community Support
Community Support

Hi @bharukc ,

 

Glad to hear that. Please accept your reply as solution. Your contribution is highly appreciated.

 

 

Best Regards,

Icey

BeaBF
Super User
Super User

@bharukc "count of study_id by year, phase on name" can you explicit this? 

 

BF.

Whitewater100
Solution Sage
Solution Sage

Hi:

There's a few ways to do this. Here I added a calculated column to the table (I named it Study).  This gets the Category 1 piece.

Study Qty = CALCULATE(COUNT(Study[study_id]), Study[category] = 1)
Then this measure:
Median 2017 =
CALCULATE(MEDIAN(Study[Study Qty]), Study[Year] = 2017)   you can change year or add another Filter Condition if needed.
 
Here are images
Whitewater100_0-1649864164661.pngWhitewater100_1-1649864198740.png

I hope this is what you are looking for..

 

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! Prices go up Feb. 11th.

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.