Forum Discussion

peterhui50's avatar
peterhui50
Icon for Helper III rankHelper III
4 years ago

date subtraction in a column

Hi,

 

I want to subtract these two dates (Date entered position) in as calculated column? is this possible?

 

Employee           Type                           Date entered position

AAdmin9/10/2010
AAdmin9/10/2010
AMgr2/12/2013
AMgr2/12/2013

 

I tried Rankx to rank both dates as 1 and 2, then can't really figure out how to subtract them after. Maybe earlier?

 

Not sure.

 

thanks!

Peter

 

 

1 Reply

  • v-kkf-msft's avatar
    v-kkf-msft
    Icon for Community Support rankCommunity Support

    Hi peterhui50 ,

     

    Do you want to calculate the current date minus the value of the previous date for each employee? Then try the following calculated column.

     

    NewColumn =
    VAR PreDate =
        CALCULATE (
            MAX ( 'Table'[Date entered position] ),
            FILTER (
                'Table',
                'Table'[Employee] = EARLIER ( 'Table'[Employee] )
                    && 'Table'[Date entered position] < EARLIER ( 'Table'[Date entered position] )
            )
        )
    RETURN
        DATEDIFF ( PreDate, 'Table'[Date entered position], DAY )

     

    If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
    Best Regards,
    Winniz
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.