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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Creative_tree88
Helper III
Helper III

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
v-cgao-msft
Community Support
Community Support

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

2 REPLIES 2
v-cgao-msft
Community Support
Community Support

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

@v-cgao-msft - many thanks indeed!

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.