Forum Discussion

NPC's avatar
NPC
Icon for Helper I rankHelper I
4 years ago
Solved

Subtract Same Row Dates

Hello,   I need to be able to subtract dates from the same row. - Specifically, I care only about the date differnce btween the Statuses "SFT" and "REA" and only if they follow each other. - If "...
  • v-zhangti's avatar
    4 years ago

    Hi, NPC 

     

    You can try the following methods.

    Column:

    Previous Date =
    MAXX (
        FILTER (
            'Table',
            [Completed On] < EARLIER ( 'Table'[Completed On] )
                && [Equip_Num] = EARLIER ( 'Table'[Equip_Num] )
        ),
        [Completed On]
    )
    
    Previous Status =
    CALCULATE (
        MAX ( 'Table'[Status] ),
        FILTER (
            'Table',
            [Equip_Num] = EARLIER ( 'Table'[Equip_Num] )
                && [Completed On] = EARLIER ( 'Table'[Previous Date] )
        )
    )
    
    Follow = IF([Status]="REA"&&[Previous Status]="SFT",1,BLANK())
    Date_Difference = IF([Follow]=1,[Completed On]-[Previous Date],BLANK())

    Is this the output you expect?

     

    Best Regards,

    Community Support Team _Charlotte

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.