Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago

Max calculation using date slicer

I have a calculation that looks for the last date we have in the data and return the value for that date:

 

Column =
VAR LASTIME = MAX(Query1[ReportDate])
RETURN CALCULATE(VALUES(Query1[OpenInventory]), (Query1[ReportDate]=LASTIME) )
 
I also have a date slicer on ReportDate but once I change the date range to anything before the max date in the data I get a blank for the calculation. I would like the calculation to pick up the max date on my slicer that I select. 

4 Replies

  • Anonymous ,

    Have selected Report Date in the slicer. Max should from the date selected in the slicer.

    try like

    Column =
    VAR LASTIME = MAXX(Query1,Query1[ReportDate])
    RETURN CALCULATE(VALUES(Query1[OpenInventory]), filter(all(Query1),Query1[ReportDate]=LASTIME) )

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thanks amitchandak I tried the following but still receiving a blank once I change the slicer:

       

      Column =
      VAR LASTIME = MAXX(Query1,Query1[ReportDate])
      RETURN CALCULATE(VALUES(Query1[OpenInventory]), filter(all(Query1[ReportDate]),Query1[ReportDate]=LASTIME) )


      • amitchandak's avatar
        amitchandak
        Super User

        Anonymous ,Can you share sample data and sample output.

  • dax's avatar
    dax
    Community Support

    Hi  Anonymous , 

    You could refer to my sample for details.

    Best Regards,
    Zoe Zhi

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