Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Variance For Specific Date Range Based on Flag (DAX)

Hi all,

 

I have some sample data below.

 

 

I want to create a calculated column that displays the variance of "PctComplete" for the previous 2 weeks of a date marked as "IsTrue". The values not marked as "IsTrue" will be BLANK.

 

I tried to do this, but got NaN values in my rows with "IsTrue = 1". I do have my date keys connected to a date dimension.

 

Var2WkBefore = IF(Example[IsTrue] = 1, CALCULATE(VARX.S(Example, Example[PctComplete]), DATESBETWEEN(DimDate[DayDate], RELATED(DimDate[DayDate]) - 14, RELATED(DimDate[DayDate]))), BLANK())

 

Any help is greatly appreciated. I also have many stores and multiple IsTrue dates, but I figured that if I can do it for one, it will work for all.

1 Reply

  • v-chuncz-msft's avatar
    v-chuncz-msft
    Community Support

    Anonymous 

     

    Try to set the relationship to One-to-One (1:1).