Forum Discussion
Euro0681
Helper II
3 years agoConversion into Power BI DAX
I'm having to create a measure that calculates a baseline value (the baseline should be previous fiscal year of the last Quarter (so q4)) I was wondering how this could be achieved, as it was provid...
- Anonymous3 years ago
Hi Euro0681 ,
I created some data:
Here are the steps you can follow:
1. Create measure.
IF1 = IF( MAX('Table'[Period]) in {"202111","202112","202201"}&& MAX('Table'[Amount1 USD])=0, MAX('Table'[Amount2 USD]), IF( MAX('Table'[Period]) in {"202111","202112","202201"}, MAX('Table'[Amount1 USD]),0))IF2 = IF( MAX('Table'[Period]) in {"202111","202112","202201"}&& MAX('Table'[Amount1])=0, MAX('Table'[Amount2]), IF( MAX('Table'[Period]) in {"202111","202112","202201"}, MAX('Table'[Amount1]),0))Sum_Amount = SUMX(FILTER(ALL('Table'),'Table'[CC]=MAX('Table'[CC])&&'Table'[Period]=MAX('Table'[Period])),[IF2])Sum_Amount USD = SUMX(FILTER(ALL('Table'),'Table'[CC]=MAX('Table'[CC])&&'Table'[Period]=MAX('Table'[Period])),[IF1])Sum_ALL = var _count= COUNTX(FILTER(ALL('Table'),'Table'[CC]=MAX('Table'[CC])&&'Table'[Period]=MAX('Table'[Period])),[Period]) var _sumall= SUMX(FILTER(ALL('Table'),'Table'[CC]=MAX('Table'[CC])&&'Table'[Period]=MAX('Table'[Period])),[Sum_Amount]+[Sum_Amount USD]) return DIVIDE( _sumall,_count)2. Result:
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
- 3 years ago
let Source = Table.SelectRows(TB, each List.Contains({"202111","202112","202201"},[Period])), #"Amount USD" = Table.AddColumn(Source, "Amt USD", each if [Amount1 USD] = 0 then [Amount2 USD] else [Amount1 USD]), Amount = Table.AddColumn(#"Amount USD", "Amt", each if [Amount1] = 0 then [Amount2] else [Amount1]), Aggregated = Table.Group(Amount, "CC", {"Aggr", each [#"Amount USD"=List.Sum([Amt USD]), Amount=List.Sum([Amt])]}), #"Expanded Aggr" = Table.ExpandRecordColumn(Aggregated, "Aggr", {"Amount USD", "Amount"}) in #"Expanded Aggr"For fun only, a showcase of powerful Excel worksheet formulas
Anonymous
3 years agoNot applicable
Hi Euro0681 ,
I created some data:
Here are the steps you can follow:
1. Create measure.
IF1 =
IF(
MAX('Table'[Period]) in {"202111","202112","202201"}&&
MAX('Table'[Amount1 USD])=0,
MAX('Table'[Amount2 USD]),
IF(
MAX('Table'[Period]) in {"202111","202112","202201"},
MAX('Table'[Amount1 USD]),0))IF2 =
IF(
MAX('Table'[Period]) in {"202111","202112","202201"}&&
MAX('Table'[Amount1])=0,
MAX('Table'[Amount2]),
IF(
MAX('Table'[Period]) in {"202111","202112","202201"},
MAX('Table'[Amount1]),0))Sum_Amount =
SUMX(FILTER(ALL('Table'),'Table'[CC]=MAX('Table'[CC])&&'Table'[Period]=MAX('Table'[Period])),[IF2])Sum_Amount USD =
SUMX(FILTER(ALL('Table'),'Table'[CC]=MAX('Table'[CC])&&'Table'[Period]=MAX('Table'[Period])),[IF1])Sum_ALL =
var _count=
COUNTX(FILTER(ALL('Table'),'Table'[CC]=MAX('Table'[CC])&&'Table'[Period]=MAX('Table'[Period])),[Period])
var _sumall=
SUMX(FILTER(ALL('Table'),'Table'[CC]=MAX('Table'[CC])&&'Table'[Period]=MAX('Table'[Period])),[Sum_Amount]+[Sum_Amount USD])
return
DIVIDE(
_sumall,_count)
2. Result:
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
- CNENFRNL3 years ago
Community Champion
let Source = Table.SelectRows(TB, each List.Contains({"202111","202112","202201"},[Period])), #"Amount USD" = Table.AddColumn(Source, "Amt USD", each if [Amount1 USD] = 0 then [Amount2 USD] else [Amount1 USD]), Amount = Table.AddColumn(#"Amount USD", "Amt", each if [Amount1] = 0 then [Amount2] else [Amount1]), Aggregated = Table.Group(Amount, "CC", {"Aggr", each [#"Amount USD"=List.Sum([Amt USD]), Amount=List.Sum([Amt])]}), #"Expanded Aggr" = Table.ExpandRecordColumn(Aggregated, "Aggr", {"Amount USD", "Amount"}) in #"Expanded Aggr"For fun only, a showcase of powerful Excel worksheet formulas