Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Help with filter one measure

Good morning,

 

hope you all are great.

 

I have a problem filtering one measure, wiosh you could help.

 

I have a table with data that is filtered by datestamps. For knowing which is the last date stamp is used the following:

 

 

 

lastdate = 
LASTDATE(airlift[phot_day_real])

 

 

 

That date is p.e. 22 - jan - 2021

 

I trying to filter the data like follows:

 

 

 

test_seats = 
CALCULATE(SUM(airlift[Seats]),
    FILTER(airlift,
        airlift[photo_day]=DATEVALUE([lastdate])))

 

 

 

but it doesn´t work....

 

But if I put the date manually it works perfectly, like this:

 

 

Total_seats = CALCULATE(
SUM(airlift[Seats]),
airlift[photo_day]=DATE(2021,1,22))

 

 

 

Can anyone help me with this¿?

 

Thanks!

 

Peter

  • Hi Anonymous 

    That is context transition working against you. Try:

    test_seats =
    VAR aux_ =
        DATEVALUE ( [lastdate] )
    RETURN
        CALCULATE (
            SUM ( airlift[Seats] ),
            FILTER ( airlift, airlift[photo_day] = aux_ )
        )

    Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

    Contact me privately for support with any larger-scale BI needs, tutoring, etc.

    Cheers 

     

     

2 Replies

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

    Hi Anonymous 

    That is context transition working against you. Try:

    test_seats =
    VAR aux_ =
        DATEVALUE ( [lastdate] )
    RETURN
        CALCULATE (
            SUM ( airlift[Seats] ),
            FILTER ( airlift, airlift[photo_day] = aux_ )
        )

    Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

    Contact me privately for support with any larger-scale BI needs, tutoring, etc.

    Cheers 

     

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      This is amazing!!! Thanks!!!! 😀