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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
Anonymous
Not applicable

DAX Measure With Multiple FILTERS

I'vw been grappling with how to write the DAX for a measure tht has a column that needs multiple filters. Here is my current DAX for the measure in question:

 

Booked Total Pax Legs:=CALCULATE( SUM( FactPassengerLeg[PassengerLegUnit] ) ,

FILTER( DimFlightLeg, DimFlightLeg[OperatorCode] = "SY") ,

FILTER( DimFlightLeg, DimFlightLeg[Flight as a Number] < 8000 ))

 

I also need to filter out on a range of values for [Flight as a Number], the range being [Flight as a Number] >=1000 and <=1099.

 

I've tried the && and the || arguments, but can't seem to get it right. I've tried the following:

 

Booked Total Pax Legs:=CALCULATE( SUM( FactPassengerLeg[PassengerLegUnit] )
, FILTER( DimFlightLeg, DimFlightLeg[OperatorCode] = "SY")
, FILTER( DimFlightLeg, DimFlightLeg[Flight as a Number] < 8000 )
, FILTER( DimFlightLeg, DimFlightLeg[Flight as a Number] < 1000 && DimFlightLeg[Flight as a Number] > 1099 ))

 

This measure essentially returns 0 because the filters filter everything out.

 

So, I'm just trying to filter on:

All flights with operator code of "SY"

All flights with a flight number of less than 8000. But also need to exclude all flights with a flight number between 1000 and 1099. Not sure how to pull this off.

 

Any insight would be awesome.

 

Thanks!!

1 REPLY 1
OwenAuger
Super User
Super User

Hi @Anonymous 

 

Generally it's best to apply filters to columns rather than entire tables.

 

In your case you have filters to apply DimFlightLeg[OperatorCode] and DimFlightLeg[Flight as a Number].

 

I would rewrite your measure something like this:

 

Booked Total Pax Legs :=
CALCULATE (
    SUM ( FactPassengerLeg[PassengerLegUnit] ),
    DimFlightLeg[OperatorCode] = "SY",
    DimFlightLeg[Flight as a Number] < 8000
        && NOT ( DimFlightLeg[Flight as a Number] >= 1000
        && DimFlightLeg[Flight as a Number] <= 1099 )
)

If you need these filters to be be intersected with existing filters, you could wrap each filter argument in KEEPFILTERS.

 

Regards,

Owen


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
LinkedIn

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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