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

ALLEXCEPT but keep a set filter as well

Hello everyone,

This has probably been asked before with a different phrasing, so thank you and apologies in advance!

Let's say my data looks like this:

ItemStoreCityStock
AHigh StreetLondon3
ALow StreetVancouver7
AMain StreetBoston3
BJubilee StreetToronto5
BFun StreetRome7
CLow StreetVancouver3
CHigh StreetLondon4

 

And my report shows the above data in various visuals (ex: Item count by City, number of stores by City, Distinct products by store, total stock by store/city, etc...).

I would like to create a Measure that:
1) SUMS the Stock
2) Item == A
3) Filters based on City if selected (ie: if you click on a City in a visual, the Measure is affected)
4) Does not filter based on anything else (ie: if you click on a Store in a visual, the Measure is not affected).

I suspect there's an ALLEXCEPT involved, but I have not been able to get it to work. Any hints? 
 

1 ACCEPTED SOLUTION
v-yinliw-msft
Community Support
Community Support

Hi @lucazanzi,

 

You can try this method:

New a measure:

Total =
CALCULATE (
    SUM ( 'Table'[Stock] ),
    ALLEXCEPT ( 'Table', 'Table'[City] ),
    FILTER ( 'Table', 'Table'[Item] = "A" )
)

And the result is:

vyinliwmsft_0-1669184592793.png

vyinliwmsft_1-1669184601573.png

 

 

Hope these help you.

Here is my PBIX file.

 

Best Regards,

Community Support Team _Yinliw

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-yinliw-msft
Community Support
Community Support

Hi @lucazanzi,

 

You can try this method:

New a measure:

Total =
CALCULATE (
    SUM ( 'Table'[Stock] ),
    ALLEXCEPT ( 'Table', 'Table'[City] ),
    FILTER ( 'Table', 'Table'[Item] = "A" )
)

And the result is:

vyinliwmsft_0-1669184592793.png

vyinliwmsft_1-1669184601573.png

 

 

Hope these help you.

Here is my PBIX file.

 

Best Regards,

Community Support Team _Yinliw

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

FreemanZ
Super User
Super User

you may also try
Measure =
CALCULATE ( 
    SUM ( Data[Stock] ), 
    ALL ( Data), 
    VALUES(Data[City])
 )
tamerj1
Super User
Super User

Hi @lucazanzi 

yes you are right. You csn use

=
CALCULATE ( SUM ( Data[Stock] ), ALLEXCEPT ( Date, Data[City] ) )

Alternatively, you can replace ALLEXCEPT with REMOVEFILTERS ( ), VALUES ( Date[City] )

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