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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Page filter and filter within measure on the same categorical column not working

Hi all,

 

I've got the data equivalent of the following:

 

ItemColorPants yes/no
PantsGreen1
pantsRed1
PantsGreen1
ShirtGreen0

 

I want to calculate how many pants+color combination are sold per customer (obtained from another table). I first calculate totals per color:

 

 

Green Pants = 
CALCULATE(SUM(Table[Pants yes/no]), Table[Color] = "Green")

 

Then the ratio

 

Green Pants Ratio = DIVIDE([Green Pants],[Customer Count],0)

 

Repeat for red. Then I add both red and green ratios to a stacked bar chart. So far so good.

 

The issue appears when I try to create a page filter for Pants = Green, and wanting the stacked bar chart to ONLY show the GREEN PANTS ratios. Instead, the green pants ratio is unaffected because I assume the measure filter overrides the page filter.

 

Potential workaround is a total [pants per customer] measure and filtering that measure by page filter colors, but then I lose the categorical stacked bar view.

 

Can you help me? Would be much appreciated!

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

Hi, @Anonymous ;

May be you could use max() replaces allexpect() as follows:

Pants = DIVIDE(CALCULATE(SUM([Pants yes/no]), FILTER('Table',[Color]=MAX([Color]))),DISTINCTCOUNT('Table (2)'[Customer]),0) 

if you want to use multiple classification conditions, you can use "&&". for example,

FILTER('Table',[Color]=MAX([Color])&&[stores]=max([stores]))

Best Regards,

Community Support Team_ Yalan Wu

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

4 REPLIES 4
v-yalanwu-msft
Community Support
Community Support

Hi, @Anonymous ;

May be you could use max() replaces allexpect() as follows:

Pants = DIVIDE(CALCULATE(SUM([Pants yes/no]), FILTER('Table',[Color]=MAX([Color]))),DISTINCTCOUNT('Table (2)'[Customer]),0) 

if you want to use multiple classification conditions, you can use "&&". for example,

FILTER('Table',[Color]=MAX([Color])&&[stores]=max([stores]))

Best Regards,

Community Support Team_ Yalan Wu

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

Anonymous
Not applicable

Thats done the trick, thanks!

Anonymous
Not applicable

Hi @v-yalanwu-msft, thank you, that answer is a solution to the problem I originally posted, but I also need to filter the results by multiple other categories (i.e. which stores, all stores within a specific region, all stores within a specific country etc). Using the allexcept nullifies the use of those filters I believe. Are there workarounds for this save for simply adding all the filters I need to allexcept?

 

Unfortunately I cannot share the file as it's confidential information and it is too large for anonimization.

v-yalanwu-msft
Community Support
Community Support

Hi @Anonymous  ,  

You could create a measure by the following formula:

Pants = 
DIVIDE(CALCULATE(SUM([Pants yes/no]), ALLEXCEPT('Table','Table'[Color])),DISTINCTCOUNT('Table (2)'[Customer]),0)

The final output is shown below:  

v-yalanwu-msft_0-1623827840188.png

And create a stacked bar chart, Pants as Values, and color as Legend ;

v-yalanwu-msft_1-1623827840193.png

 

When you filter Pants = Green, Pictures are as follows:

v-yalanwu-msft_2-1623827840195.png

The above is my understanding, I am not very sure whether your needs are met, if I understand wrong, please share more details or remove the pbix of sensitive data.

Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.  

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors