Forum Discussion
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.
Kind regards
- Anonymous3 years ago
Hi Creative_tree88 ,
First you need a table like:
relationships:
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:
Best Regards,
Gao
Community Support TeamIf 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!
2 Replies
- AnonymousNot applicable
Hi Creative_tree88 ,
First you need a table like:
relationships:
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:
Best Regards,
Gao
Community Support TeamIf 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
- Creative_tree88
Helper V
Anonymous - many thanks indeed!