Forum Discussion
calculate measure help..
- 5 years ago
- Anonymous5 years ago
Hi srk_powerbi ,
Based on your sample data, you can create the following measure. My measure is updated dynamically, no slicer selection is required.
% cexpected = var _aa=CALCULATE(SUM('Table'[Amount]),FILTER('Table',[CalcType]="sales"&&[Fy]<=YEAR(TODAY())&&[Fm]<=MONTH(TODAY()))) var _bb=CALCULATE(SUM('Table'[Amount]),FILTER('Table',[CalcType]="sales expected"&&[Fy]<=YEAR(TODAY())&&[Fm]<=MONTH(TODAY()))) return DIVIDE(_aa-_bb,_aa)Tips: [Fm] column is a calculated column which retruns the month number.
Best Regards,
Stephen Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
srk_powerbi , In case you have date or can create a date then you can use time intelligence with date table
example
calculate([% cexpected], datesmtd('Date'[Date])
else create a separate table with year month (say date)
add rank column
Month Rank = RANKX(all('Date'),'Date'[year Month],,ASC,Dense)
create measures
This Month = CALCULATE([% cexpected], FILTER(ALL('Date'),'Date'[Month Rank]=max('Date'[Month Rank])))
Last Month = CALCULATE([% cexpected], FILTER(ALL('Date'),'Date'[Month Rank]=max('Date'[Month Rank])-1))
thanks for reply. here I need to calculate for all the months prior to current month dynamically.