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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
ARLYS6
Frequent Visitor

Median per categories

I would like to create a card from my table called 'Debt' that provides the median debt per student [Id] per program [Program]. I have the used the following calcuation to do it per student, but I cannot figure out how to add the additional element of per program. We have several students at our institution who graduate from one program and enroll in another.

 

MEDIANX (

KEEPFILTERS(VALUES('Debt' [Id])).

CALCULATE(SUM('Debt' [Total])))

 

Thank you in advance for any insight.

4 REPLIES 4
andhiii079845
Solution Sage
Solution Sage

Oh, you want only a card / one measure per both categories. Try this:
You have to create a virtual table with the sum values and than you can do the medianx

Measure = 
Var __table = SUMMARIZE(Debt,Debt[ID],Debt[Programm],"__sum",sum(Debt[Total]))
RETURN MEDIANX(__table,[__sum])




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




andhiii079845
Solution Sage
Solution Sage

HI,

 

i try this with the raw data (left) and right the matrix with the median measure:

andhiii079845_1-1677508973237.png

The median will calculated within the groups.

The measure:

Measure = MEDIANX(Debt,Debt[Total])




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




andhiii079845
Solution Sage
Solution Sage

Here is a example in the end of the article where two filters are used in keepfilters:
https://www.sqlbi.com/articles/using-keepfilters-in-dax/





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Thanks. That makes sense when trying to get calcuate the sum, but I still cannot figure out how to do it when I need the median of the sum for 2 filters/categories.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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