Forum Discussion

Emranit's avatar
Emranit
Helper II
1 year ago
Solved

Need a help regarding latest date by DAX

I have a production related dashboard which connected from SQL server. Here I manually select Date and found Production according to selecting date. I need a DAX which will be work for show latest da...
  • DataNinja777's avatar
    1 year ago

    Hi Emranit ,

     

    To display the latest available production date and corresponding data in your Power BI dashboard using DAX, you can create a measure that always returns the maximum (latest) available date from your dataset. You can define it as follows:

    Latest_Date = MAX('YourTable'[EndTime])
    

    Once you have the latest date, you need another measure that filters and sums the Weight column for that latest available date.

    Latest_Production = 
    CALCULATE(
        SUM('YourTable'[Weight]),
        'YourTable'[EndTime] = [Latest_Date]
    )
    

    If you want to ensure that the dashboard always shows data up to the last completed day (yesterday) instead of the maximum available date (which might include future dates), you can modify the Latest_Date measure like this:

    Latest_Date = 
    CALCULATE(
        MAX('YourTable'[EndTime]),
        'YourTable'[EndTime] <= TODAY()-1
    )
    

    With these measures, when a user opens the dashboard, the visuals will dynamically display the production data for the most recent day that has available data. If today is March 1, 2025, the dashboard will show the data for February 28, 2025. As new data is added, the dashboard will automatically update to reflect the latest production date and values.

     

    Best regards,