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 date and data according to latest date. When a user open the Dashboard it will be show last day date & data. Suppose today 1st March, Dashboard will be present 28 February  with  production Data.

 

https://docs.google.com/spreadsheets/d/12XphOetMX17Z5m3iC4MKbGEWMooGm-wd/edit?usp=drive_link&ouid=113914284006601104314&rtpof=true&sd=true

 

https://drive.google.com/file/d/1CvQJI7FQarN0Ksosjx_6Qml5ymYs5ad6/view?usp=drive_link

 

In the link, there are 2 files for an example. Please help me in this regard.

  • 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,

4 Replies

  • 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,

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Emranit,

    Thanks for reaching out to the Microsoft fabric community forum.

     

    It looks like you are looking for a DAX Query which will show the latest date and data accordingly. As DataNinja777 already provided a response to your queries, please go through it and accept it as solution if it helps you in solving the issue.

     

    I would also take a moment to thank DataNinja777, for actively participating in the community forum and for the solutions you’ve been sharing in the community forum. Your contributions make a real difference.

     

    If I misunderstand your needs or you still have problems on it, please feel free to let us know.  

    Best Regards,
    Hammad.
    Community Support Team

     

    If this post helps then please mark it as a solution, so that other members find it more quickly.

    Thank you.