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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Shawel_pl
New Member

Return only max value by filter

Hello

 

I'd like to ask you to solve the problem with my dax. I want to return the max value for each filter (product). For example for product one returned value should be 50, for product 2 25, for product 3 100. 

IMG_6458.jpeg

3 ACCEPTED SOLUTIONS
DataNinja777
Super User
Super User

Hi @Shawel_pl 

There are many ways to achieve your required output, and one of them is like below:

DataNinja777_0-1714724925181.png

Best regards,

 

View solution in original post

AntrikshSharma
Community Champion
Community Champion

@Shawel_pl 

Max Length = 
CALCULATE ( 
    MAX ( 'Table'[Length] ), 
    ALLEXCEPT ( 'Table', 'Table'[Product] ) 
)

View solution in original post

v-zhouwen-msft
Community Support
Community Support

Hi @AntrikshSharma , @AntrikshSharma ,thanks for the quick replies, I'll add further.

Hi @Shawel_pl ,

Regarding your question, I think there is no problem. Dax's calculation environment is divided into external filter conditions and internal filter conditions, the internal filter conditions will override the external filter conditions. 'ALLEXCEPT' function will clear the corresponding external filter conditions, you can only set up the corresponding internal filter conditions in dax.

 

 

 

 

 

View solution in original post

6 REPLIES 6
v-zhouwen-msft
Community Support
Community Support

Hi @AntrikshSharma , @AntrikshSharma ,thanks for the quick replies, I'll add further.

Hi @Shawel_pl ,

Regarding your question, I think there is no problem. Dax's calculation environment is divided into external filter conditions and internal filter conditions, the internal filter conditions will override the external filter conditions. 'ALLEXCEPT' function will clear the corresponding external filter conditions, you can only set up the corresponding internal filter conditions in dax.

 

 

 

 

 

AntrikshSharma
Community Champion
Community Champion

@Shawel_pl 

Max Length = 
CALCULATE ( 
    MAX ( 'Table'[Length] ), 
    ALLEXCEPT ( 'Table', 'Table'[Product] ) 
)

Do you think I could include 2 or more allexcept filters to that formula if I'd like to group it by 2 or more column? 

Yes, for the same table you can include columns from that table in single ALLEXCEPT, when using ALLEXCEPT on Many side you can include even the entire table on the one side: ALLEXCEPT ( Fact, Dimension1, Dimension2, Dimension2[Col1], Dimension3[Col2] )

Thanks

one more question. I have set up filters for example I set up filter to disable product number 2 to be seen in table. Though  It's not seen in visualization the value is still being grabbed by dax and if the value from product number 2 is the largest then dax returns it as biggest value among products 1-3 even though number 2 is disabled. How to execute the filter? 

I guess I found the way. In my formula I added filter product<>"2"

do you think it's a good way to include the filter within all except function? 

DataNinja777
Super User
Super User

Hi @Shawel_pl 

There are many ways to achieve your required output, and one of them is like below:

DataNinja777_0-1714724925181.png

Best regards,

 

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.