Forum Discussion
How to write an IF measure when using different time periods
- 5 years ago
Try this measure:
YTD New = IF ( MAX ( Table1[Name] ) = "Cash", [YTD Mar 2020], MAX ( Table1[YTD] ) ) - Anonymous5 years ago
Hi SonyT01 ,
According to your description and my previous experience, I guess you seem to mix measures and calculated columns. It does not meet the definition rules of DAX functions.
This error can happen when a measure formula refers to a column that contains many values without specifying an aggregation such as min, max, count, or sum to get a single result.
Result:
I think you can modify the "YTD NEW" measure appropriately as follows.
YTD NEW =
var min_value=MIN('Table 1'[Name])
return
IF(
min_value="cash",
'Table 1'[YTD Mar 2020],
MIN('Table 1'[YTD])
)
Result:
I hope my suggestion can give you some help.
Best Regards,
Yuna
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- 5 years ago
Thank you so much!! I have been trying to figure this out with no success. This has achieved the result I was after.
Many thanks again!
Try this measure:
YTD New = IF ( MAX ( Table1[Name] ) = "Cash", [YTD Mar 2020], MAX ( Table1[YTD] ) )
Thank you for your help. It did work well for each category, but not for the total amount.
I was trying to calculate a % of accomplishment for each category, but the Total % achievement it just sums each category, it doesn't calculate the correct amount.
Do you know how can i fix it?