Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Tresor
Regular Visitor

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

1 ACCEPTED SOLUTION
AlB
Super User
Super User

Hi @Tresor 

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 

 

SU18_powerbi_badge

 

View solution in original post

2 REPLIES 2
AlB
Super User
Super User

Hi @Tresor 

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 

 

SU18_powerbi_badge

 

Tresor
Regular Visitor

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

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.