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
Chocapsuro
New Member

Double filter in same table/column

Hi,

 

I have an Excel File with a list of aircraft with the main characteristics of each one (airline, model, manufacturer, age...). I want to identify, per model, which is the position of each aircraft per age: e.g. for all A320 if aircraft X is 19.8 years old, how many aircraft are older than it (that is the order of age filtered by model). I wouldn't like to use an auxiliary table as I want to further elaborate on this table.

When it comes to calculate the number of aircraft per model I use the following formula:

 

Aicraft per Model = CALCULATE(COUNT(Table 'Aicraft Name'), ALLEXCEPT ( Table, Table 'Aicraft Model'))

 

And it works, but I do not know how to calculate the next step, that would be the number of aircraft within the list that are older than the row/aircraft that is evaluated. I have tried the following without success:

 

Aicraft Age Order = CALCULATE(COUNT(Table 'Aicraft Name'), FILTER( ALLEXCEPT ( Table, Table 'Aicraft Model') , Table 'Aicraft Age' > Table 'Aicraft Age' ))

 

Could someone help me with this? Thank you very much!

 

Chocapsuro

 

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

@Chocapsuro Try:

Aircraft Older Than Measure =
  VAR __Model = MAX('Table'[Aircraft Model])
  VAR __Age = MAX('Table'[Aircraft Age])
  VAR __Table = FILTER(ALL('Table'),[Model] = __Model && [Aircraft Age] > __Age)
RETURN
  COUNTROWS(__Table)

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

2 REPLIES 2
Greg_Deckler
Super User
Super User

@Chocapsuro Try:

Aircraft Older Than Measure =
  VAR __Model = MAX('Table'[Aircraft Model])
  VAR __Age = MAX('Table'[Aircraft Age])
  VAR __Table = FILTER(ALL('Table'),[Model] = __Model && [Aircraft Age] > __Age)
RETURN
  COUNTROWS(__Table)

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Hi @Greg_Deckler ! Using variables it works perfectly, thank you very much!

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.

Top Solution Authors