Forum Discussion

khush19's avatar
khush19
Icon for Resolver I rankResolver I
5 years ago

Filter on datetime column sometime work ,sometime not

I am working on report ,where i need to take the amount based on latest datetime.

For this i created a measure

Total Calculated Amount = CALCULATE(sum(ParkingSessionSA[TotalAmount]),FILTER(ParkingSessionSA,ParkingSessionSA[CurrentTime]=MAX(ParkingSessionSA[CurrentTime])))
 
Somethimes measure show value ,sometimes not,not able to figure out why

 

9 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Icon for Community Champion rankCommunity Champion

    khush19 Betting there is probably a reason. Unfortunately, not really enough information to go on. What exactly are you trying to accomplish with that measure because it seems like it could just be:

    sum(ParkingSessionSA[TotalAmount])

     

    Please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882

    Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

    The most important parts are:
    1. Sample data as text, use the table tool in the editing bar
    2. Expected output from sample data
    3. Explanation in words of how to get from 1. to 2.

    • khush19's avatar
      khush19
      Icon for Resolver I rankResolver I

      HI Greg,

       

      I have data like :

      now i need to get Amount based on max (currenttime).

      For this i created a measure and this measure is used in many measure to calculate difference ,% change.

      and the worst part is it,this measure works sometimes and sometimes not.

      and it work in SIT,UAT and fail only in PROD 😞

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

        khush19 , You expected output is not clear. Max on the row context as good as row values unless there is some logic added

        Try

        Total Calculated Amount =
        var _max =MAXX(ParkingSessionSA,ParkingSessionSA[CurrentTime])
        return
        CALCULATE(sum(ParkingSessionSA[TotalAmount]),FILTER(ParkingSessionSA,ParkingSessionSA[CurrentTime]=_max))

         

        Can you share sample data and sample output in a table format? Or a sample pbix after removing sensitive data.