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
sdgiss
Helper I
Helper I

Maintaining filter context after applying ALL function

First off, let me state that I am very new to DAX. The question I have relates to maintaining filter context after applying the ALL function to create a new measure.

The new measure identifies the all-time (ALL dDates) best max speed for each bike racer. When reporting daily max speed on a specific date, there are records for those who did not record a value on that date (but did over the previous year). I realize this is probably a simple solution but I am struggling to have both the date filter context in the pivot table and the all-time best measure for only those racers that recorded a max speed on that specific date. I would only like to report an all-time best max speed for those that had a max speed record on a specific date. My pivot table is below with a specific example where Racer 9 & 10 have no data for 10/21 but still show up because they have an all-time max speed. The DAX formulae are as follows:

Max Speed All Dates = CALCULATE ( MAX ( fData[Max Speed] )FILTER ( ALL ( dDate ), dDate[Date] ) )

Max Speed per Racer =CALCULATE(MAX(fDataReference[Max Speed]),ALLEXCEPT(dRacerDetail,dRacerDetail[Racer]))

 

Thank you!

 

Steve

 

Max Speed.png

1 ACCEPTED SOLUTION
wdx223_Daniel
Super User
Super User

@sdgiss  just adding a if function in your measure

Max Speed All Dates = IF([Daily Max],CALCULATE ( MAX ( fData[Max Speed] ), FILTER ( ALL ( dDate ), dDate[Date] ) )))

View solution in original post

6 REPLIES 6
CNENFRNL
Community Champion
Community Champion

Hi, @amitchandak , @Anonymous , @wdx223_Daniel , a quick question please: can you guys shed some light on this expression?

FILTER ( ALL ( dDate ), dDate[Date] )

what's the differece between it and ALL ( dDate )? Thanks in advance!


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

@CNENFRNL there is no need for the use of FILTER in this formula, as ALL is more than enough to achieve the result. My immature DAX brain was overcompensating with FILTER when writing this measure.

wdx223_Daniel
Super User
Super User

@sdgiss  just adding a if function in your measure

Max Speed All Dates = IF([Daily Max],CALCULATE ( MAX ( fData[Max Speed] ), FILTER ( ALL ( dDate ), dDate[Date] ) )))

This is the one! Thank you so much @wdx223_Daniel!!

Anonymous
Not applicable

@sdgiss   Hey Mate ,

You can try this .

 

Max Speed All Dates = if(HASONEVALUE(dDate[Date]),
                                     CALCULATE ( MAX ( fData[Max Speed] )FILTER ( ALL ( dDate ), dDate[Date] ) ),Blank() )

 


Max Speed per Racer =if(HASONEVALUE(dRacerDetail[Racer]), CALCULATE(MAX(fDataReference[Max Speed] ),Blank() )

Try this and let me know
You can use this as well.

 

 

amitchandak
Super User
Super User

@sdgiss , Try like

Max Speed All Dates = CALCULATE ( MAX ( fData[Max Speed] ), FILTER ( ALL ( dDate ), dDate[Date] ) ,not(isblank(fData[Max Speed] )) )

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