Forum Discussion

Hardy2617's avatar
Hardy2617
New Member
10 months ago
Solved

Power Bi latest Date column

I have multiple date columns, and I need latest date in a column, tried using  MAXX , but still not getting correct date for some rows.  is there any concrete DAX formula do do that?
  • KarinSzilagyi's avatar
    KarinSzilagyi
    10 months ago

    Sorry Hardy2617, I really need new glasses. I missed the part that you have multiple columns to compare 🫣

    Do you need the highest date out of the three columns overall or the highest per row?

    Highest date between the three columns for each row:

    Highest Date per Row = 
    VAR DatesTable =
        FILTER(
            {
                ( [DateID] ),
                ( [Date2] ),
                ( [Date3] )
            },
            [Value] <> BLANK()
        )
    RETURN
    MAXX ( DatesTable, [Value] )

     

    -----------------------

     

    Highest date overall accross all rows:

     

    Highest Date All Columns overall = 
    VAR AllDates =
        UNION(
            SELECTCOLUMNS( 'FactTable', "date", 'FactTable'[DateID] ),
            SELECTCOLUMNS( 'FactTable', "date", 'FactTable'[Date2] ),
            SELECTCOLUMNS( 'FactTable', "date", 'FactTable'[Date3] )
        )
    RETURN
    MAXX( FILTER(AllDates, NOT ISBLANK([date])), [date] )

     

  • danextian's avatar
    10 months ago

    Hi Hardy2617 

     

    Try the following:

    Max acrross rows (calc column) = 
    MAXX (
        {
            data[Start Date],
            data[End Date],
            data[Order Date],
            data[Delivery Date],
            data[Payment Date]
        },
        [Value]
    )
    

     

    MEASURES: 
    Max date across columns & rows = 
    CALCULATE (
        MAXX (
            {
                MAX ( data[Delivery Date] ),
                MAX ( data[End Date] ),
                MAX ( data[Payment Date] ),
                MAX ( data[Start Date] )
            },
            [Value]
        ),
        REMOVEFILTERS ( data )
    )
    
    
    Max date across rows = 
    MAXX (
        {
            MAX ( data[Delivery Date] ),
            MAX ( data[End Date] ),
            MAX ( data[Payment Date] ),
            MAX ( data[Start Date] )
        },
        [Value]
    )