Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago

Time Intelligence: Measure within a Measure within a Measure

Hi,

 

I have the below measure:

Count of Apples = DISTINCTCOUNT('TableA'[Apple_SK])
 
I now want to use this measure within a second measure:
 
Count of Apples Exited =
CALCULATE(
    [Count of Apples],
    NOT ISBLANK(TableB[Apple Exit Date])
)
 
TableA -> TableB on Apple_SK
 
I now want to use the second measure in a third measure:
 
Count of Apples Rolling 1 Qtr =
VAR __lastDate = LASTDATE( TableB[Apple Exit Date] )
VAR __result =
CALCULATE(
    [Count of Apples Exited],
    DATESINPERIOD( TableB[Apple Exit Date], __lastDate, -1, QUARTER )
    )
RETURN
    __result
 
I only get the correct result from my third measure if I use the first measure and not the second measure within it...
 
Count of Apples Rolling 1 Qtr =
VAR __lastDate = LASTDATE( TableB[Apple Exit Date] )
VAR __result =
CALCULATE(
    [Count of Apples],
    DATESINPERIOD( TableB[Apple Exit Date], __lastDate, -1, QUARTER )
    )
RETURN
    __result
 
Why can I not use [Count of Apples Exited] to calculate the rolling latest quarter result? The [Count of Apples Exited] result is returned, as if the DATESINPERIOD filter is not being applied?
 
Thanks.