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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply

Median based on multiple conditions

Hi - Im trying, but failing on this one...I need to calculate median values based on a field (Req to Att) but I need it to look only at Current Week (identifed as column 'Period') and also a specific report name called 'Reporting'.  

 

I then need to calculate the difference between current week and previous week, and also current week to 6 months ago.

 

Bit confused...I've attached a sample file with the sort of answer I'm looking to show in a table, all together, in Power BI.

 

Many thanks in advance for your help.

 

Median Sample Data 

 

Kind regards

 

 

2 ACCEPTED SOLUTIONS
Anonymous
Not applicable

Hi @Creative_tree88 ,

 

First you need a table like:

vcgaomsft_0-1673493684681.png

relationships:

vcgaomsft_1-1673493713079.png

then please create these measures:

 

Attend = CALCULATE(MEDIAN('Table'[Req to Att]),'Table'[Type]="Attend")
Attend' Change = 
VAR _index = MAX('Table2'[Index])
VAR _pre = CALCULATE([Attend],FILTER(ALLSELECTED('Table2'),'Table2'[Index]=_index-1))
VAR _change = [Attend] - _pre
RETURN
IF(_pre<>BLANK(),_change)
Reporting = CALCULATE(MEDIAN('Table'[Req to Att]),'Table'[Type]="Reporting")
Reporting' Change = 
VAR _index = MAX('Table2'[Index])
VAR _pre = CALCULATE([Reporting],FILTER(ALLSELECTED('Table2'),'Table2'[Index]=_index-1))
VAR _change = [Reporting] - _pre
RETURN
IF(_pre<>BLANK(),_change)

 

result:

vcgaomsft_2-1673493798041.png

Best Regards,
Gao

Community Support Team

 

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 on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

View solution in original post

@Anonymous - many thanks indeed!

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @Creative_tree88 ,

 

First you need a table like:

vcgaomsft_0-1673493684681.png

relationships:

vcgaomsft_1-1673493713079.png

then please create these measures:

 

Attend = CALCULATE(MEDIAN('Table'[Req to Att]),'Table'[Type]="Attend")
Attend' Change = 
VAR _index = MAX('Table2'[Index])
VAR _pre = CALCULATE([Attend],FILTER(ALLSELECTED('Table2'),'Table2'[Index]=_index-1))
VAR _change = [Attend] - _pre
RETURN
IF(_pre<>BLANK(),_change)
Reporting = CALCULATE(MEDIAN('Table'[Req to Att]),'Table'[Type]="Reporting")
Reporting' Change = 
VAR _index = MAX('Table2'[Index])
VAR _pre = CALCULATE([Reporting],FILTER(ALLSELECTED('Table2'),'Table2'[Index]=_index-1))
VAR _change = [Reporting] - _pre
RETURN
IF(_pre<>BLANK(),_change)

 

result:

vcgaomsft_2-1673493798041.png

Best Regards,
Gao

Community Support Team

 

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 on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

@Anonymous - many thanks indeed!

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors