Forum Discussion
cathyPB
6 years agoFrequent Visitor
IF statement with Calculated Measure
I would like to create a new measure with some value like this:
IF Before today:
CALCULATE(
SUM('DataMart'[ACTUAL]),
FILTER(
ALLSELECTED('DIM_DATE'[DAY_DATE]),
ISONORAFTER('DIM_DATE'[DAY_DATE], max(DIM_DATE[DAY_DATE]), DESC)))
If it After today: 0
Any suggestions?
- Anonymous6 years ago
cathyPB - Does this measure work?:
Your Measure 2 = var _Date_As_Of = MAX('Dim_Date'[Day_Date]) return CALCULATE( SUM('DataMart'[ACTUAL]), FILTER( ALL('Dim_Date'), AND(_Date_As_Of < TODAY(), 'Dim_Date'[Day_Date] <= _Date_As_Of) ) )
10 Replies
- AnonymousNot applicable
cathyPB - Could you please clarify: are you wanting to compare the fact table date vs today's date and return 0 if it's in the future?
- cathyPBFrequent Visitor
Yes, I do have Date dimension as well.
- AnonymousNot applicable
cathyPB - Check whether this Measure works:
Your Measure = CALCULATE( SUM('DataMart'[ACTUAL]), FILTER( 'Dim_Date', 'Dim_Date'[Day_Date] < TODAY() ) )I hope this helps. If it does, please Mark as a solution.
I also appreciate Kudos.