Forum Discussion

jaybertx's avatar
jaybertx
Regular Visitor
2 years ago
Solved

Compare Dates by Index

Hi everyone!   I have been hammering on this for a few weeks and every time I think I have the answer I end up going in circles. Hopefully someone can help point me in the right direction. I have d...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi  jaybertx ,

     

    Here are the steps you can follow:

    1. Create calculated column.

    Count =
    var _next=
    MAXX(
        FILTER(ALL('Table'),'Table'[Payroll ID]=EARLIER('Table'[Payroll ID])&&'Table'[Orientation Index]=EARLIER('Table'[Orientation Index])+1),[Orientation Index])
    var _nextdate=
    MAXX(
        FILTER(ALL('Table'),
        'Table'[Payroll ID]=EARLIER('Table'[Payroll ID])&&'Table'[Orientation Index]=_next),[Orientation Date])
    var _datediff=
    DATEDIFF(
        'Table'[Orientation Date],_nextdate,MONTH)
    return
    IF(
        'Table'[Orientation Index]=1,"Y",
        IF(
            _datediff>=6,"Y","N"))

    2. Result:

    When [Payroll ID]=1233 and [Orientation Index]=2, the date difference from [Orientation Index]=3 is only 2 months, which is less than 6 months, so it is N

     

    Best Regards,

    Liu Yang

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