Forum Discussion

_Kelz0484's avatar
_Kelz0484
Frequent Visitor
1 year ago
Solved

Latest date with a clause

Hi,

Bit of an odd one! I have a dataset which includes 2 x date columns, 'test date' and 'concessed date' I would like to create a new column called 'master date' which looks at the other 2 columns and gives the furthest date in the future. But there is a clause, there could be blanks in either column and in most instances where there is a date in both columns the concessed date is furthest in the future. But I have found a couple of instances where the test date and concessed date are populated and the concessed date is earlier, if this happens I need the earlier concessed date to be master instead.

 

I guess the easiest way to put it, master date to be the furthest date in the future unless concessed date comes first. Some sample data below.

 

  • _Kelz0484 

     

    SWITCH (
        TRUE (),
        ISBLANK ( 'Table'[Concessed Date] ) && ISBLANK ( 'Table'[Test Date] ), TODAY(),
        ISBLANK ( 'Table'[Concessed Date] ), 'Table'[Test Date],
        ISBLANK ( 'Table'[Test Date] ), 'Table'[Concessed Date],
        'Table'[Concessed Date] < 'Table'[Test Date], 'Table'[Concessed Date],
        MAX ( 'Table'[Test Date], 'Table'[Concessed Date] )
    )

     

    If this now works, please accept as the solution for others with the same challenge.

6 Replies

  • _Kelz0484 - Try this as a calculated column:

     

    MAX( Table[Test Date], Table[Concessed Date] )

     

    It will ignore blanks and always give you the latest date from both columns.

     

    If this works, please accept as the solution for others with the same challenge.

    • _Kelz0484's avatar
      _Kelz0484
      Frequent Visitor

      Hi, this is similar to what I am already using and yes it works for giving me the latest date but it doesn't help with the odd instances where the earlier concessed date is found.

      Thanks!

      • mark_endicott's avatar
        mark_endicott
        Icon for Super User rankSuper User

        _Kelz0484 - Sorry I misread your requirement the below will now work:

         

        SWITCH (
            TRUE (),
            ISBLANK ( 'Table'[Concessed Date] ), 'Table'[Test Date],
            ISBLANK ( 'Table'[Test Date] ), 'Table'[Concessed Date],
            'Table'[Concessed Date] < 'Table'[Test Date], 'Table'[Concessed Date],
            MAX ( 'Table'[Test Date], 'Table'[Concessed Date] )
        )

         

         

        If this now works, please accept as the solution for others with the same challenge.