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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Frajzerr
New Member

Combining AllSELECTED with ALLEXCEPT

Hello,

 

Let's say I have a visual table like below and my problem regards to AvgNumber measure.

To make it simple I'am going to split the problem into a few steps.

 

First visual(table) below shows AvgNumber as basic Average(number) 

Product Type DateNumber AvgNumber
AFG31.01.2022    1010
AFG15.01.2022    2020
CGG15.05.2022    5050
DGT16.07.2022    4040

 

What I want to do is remove visual filter context from Date column, but keep context of Product and Type. I did it using Calculate + Allexcept, Calculate(average(number), allexcept(Table,Product,Type)), results below:

Product TypeDateNumber AvgNumber
AFG31.01.2022    1015
AFG15.01.2022    20

15

CGG15.05.2022    5050
DGT16.07.2022    4040

And it is working just fine, but I also want to have a slicer on Date which needs to have an impact on AvgNumber, so let's say I have a slicer with date > 15.01.2022

Product TypeDateNumber AvgNumber
AFG31.01.2022   10

15

CGG15.05.2022   5050
DGT16.07.2022   4040

As you can see slicer removed row 2 from visual but AvgNumber measure calculated it anyway(and it make sense cause Date column was removed from filter context and it takes all Date fields it has in fact table for current product and type). So I tried to use AllSelected(date) as second filter of calculate but it didn't work. Using Calculate(Average(Number),AllSelected(table) shows on each line Avg of all Number in current filter context(when slicer is still > 15.01.2022)like below:

Product TypeDateNumber AvgNumber
AFG31.01.2022   1033,33
CGG15.05.2022   5033,33
DGT16.07.2022   4033,33

 

So basically what I want to achieve is create the AvgNumber measure which keeps visual context for two columns(Product, Type) except one(Date), but the one which is excluded(Date) should be measured by slicer.

Expected results with date slicer > 15.01.2022

Product TypeDateNumber AvgNumber
AFG31.01.2022   1010
CGG15.05.2022   5050
DGT16.07.2022   4040

Expected results with date slicer unrestricted

Product TypeDateNumber AvgNumber
AFG31.01.2022   1015
AFG15.01.2022   20

15

CGG15.05.2022   5050
DGT16.07.2022   4040

 

It looks simple but I struggle...

 

Thanks in advance for any help!

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Frajzerr , Try like

 

calculate(Average(Table[Number]), filter(allselected(Table), Table[Product]  = max(Table[Product]) && Table[Type]  = max(Table[Type])) )

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@Frajzerr , Try like

 

calculate(Average(Table[Number]), filter(allselected(Table), Table[Product]  = max(Table[Product]) && Table[Type]  = max(Table[Type])) )

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@amitchandak 

 

Thank you !!

It is working great, would you be so kind to give a short explanation of what your DAX query actually did ? 

I mean you propably used Filter to be able to use expressions in Calculate filter field right ? But I don't understand what field = max(field) is doing.

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.