Forum Discussion

dmurali1829's avatar
dmurali1829
Regular Visitor
4 years ago
Solved

Calculate Date diff based on selected category

Hi   In the below table i want to calculate date difference keeping one category in Day as 0, in this case Day 0 as 0 and it should considering for substrating other dates eiher + or -, i will be h...
  • v-jingzhang's avatar
    4 years ago

    Hi dmurali1829 

     

    You can create a column with below DAX.

    Date Diff = 
    VAR _day0 =
        MAXX (
            FILTER (
                TableName,
                TableName[ID] = EARLIER ( TableName[ID] )
                    && TableName[Day] = "Day 0"
            ),
            TableName[Date]
        )
    RETURN
        DATEDIFF ( _day0, TableName[Date], DAY )
    

     

    Best Regards,
    Community Support Team _ Jing
    If this post helps, please Accept it as Solution to help other members find it.