Forum Discussion
elliee
3 years agoFrequent Visitor
Dynamic measure based on user input
i'd like to create a table in Power BI using two measures that are based on different time period. the report is generated in Tableau today through the combined use of parameters and calculated field...
Anonymous
3 years agoNot applicable
Hi elliee ,
I created some data:
Here are the steps you can follow:
1. Create calculated table.
Measure_Slicer1 =
SUMMARIZE('Table','Table'[Year],'Table'[Month])
Measure_Slicer2 =
SUMMARIZE('Table','Table'[Year],'Table'[Month])
2. Create measure.
Flag =
var _select1year=SELECTCOLUMNS('Measure_Slicer1',"year",[Year])
var _select1month=SELECTCOLUMNS('Measure_Slicer1',"month",[Month])
var _select2year=SELECTCOLUMNS('Measure_Slicer2',"year",[Year])
var _select2month=SELECTCOLUMNS('Measure_Slicer2',"month",[Month])
return
IF(
AND(
MAX('Table'[Year]) in _select1year , MAX('Table'[Month]) in _select1month)
||
AND(
MAX('Table'[Year]) in _select2year , MAX('Table'[Month]) in _select2month),1,0)
3. Place [Flag]in Filters, set is=1, apply filter.
4. Result:
[Revenue] and [Cost] set to Sum.
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
elliee
3 years agoFrequent Visitor
Hi Yang, instead of returning both the cost and revenue for the two selected periods, can we only return the cost for the selected cost period and the revenue for the selected revenue period?
THe end goal is to use these two values to calculate the margin.
e.g. Revenue from FY2022 January / Cost from FY2021 November = Margin