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'[DA...
- 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) ) )
Anonymous
6 years agoNot 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?
- cathyPB6 years agoFrequent Visitor
Yes, I do have Date dimension as well.
- Anonymous6 years agoNot 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.- cathyPB6 years agoFrequent Visitor
Thanks for reply, but I would like to get accumulative sum result as following:
CALCULATE(
SUM('DataMart'[ACTUAL]),
FILTER(
ALLSELECTED('DIM_DATE'[DAY_DATE]),
ISONORAFTER('DIM_DATE'[DAY_DATE], max(DIM_DATE[DAY_DATE]), DESC)))