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
Cling
Frequent Visitor

Context Filter: Problem with slicer

Hello!

 

I have a matrix with the category field in the rows and the total sales with the associate percentage in the columns. Additionally, I have a slicer with the categories to be able to filter. The desired behavior is that when you filter through the slicer, the percentage of sales is with respect to the total of that section, while if you do not filter anything in the slicer, it is with respect to the total. The problem is that the filter context is interfering with my implementation of this conditional.

 

An example is attached below:

 

Category Values: Cars, Bikes, Other

 

 

category.png              

 

Thanks in advance

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Cling ,

Thanks for danextian's reply!
And @Cling , here is my sample data:

vjunyantmsft_0-1733885308431.png

To achieve your desired result, you must have another table to create a slicer:

vjunyantmsft_1-1733885346168.png

There is no relationship:

vjunyantmsft_2-1733885365446.png

Then you can use this DAX to create a measure and put it into the table visual:

Sales Percentage = 
VAR _total = 
CALCULATE(
    SUM('Table'[Sales]),
    ALL('Table'),
    'Table'[Category] IN VALUES(Slicer[Category])
)
RETURN
SUM('Table'[Sales]) / _total

vjunyantmsft_3-1733885416053.png

Then you need another DAX to create a measure as a filter for the table visual:

DaxFilter = 
IF(
    MAX('Table'[Category]) IN VALUES(Slicer[Category]),
    1,
    0
)

vjunyantmsft_4-1733885510141.png


And the final output is as below:

vjunyantmsft_5-1733885537343.png

vjunyantmsft_6-1733885545456.png


Best Regards,
Dino Tao
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

2 REPLIES 2
Anonymous
Not applicable

Hi @Cling ,

Thanks for danextian's reply!
And @Cling , here is my sample data:

vjunyantmsft_0-1733885308431.png

To achieve your desired result, you must have another table to create a slicer:

vjunyantmsft_1-1733885346168.png

There is no relationship:

vjunyantmsft_2-1733885365446.png

Then you can use this DAX to create a measure and put it into the table visual:

Sales Percentage = 
VAR _total = 
CALCULATE(
    SUM('Table'[Sales]),
    ALL('Table'),
    'Table'[Category] IN VALUES(Slicer[Category])
)
RETURN
SUM('Table'[Sales]) / _total

vjunyantmsft_3-1733885416053.png

Then you need another DAX to create a measure as a filter for the table visual:

DaxFilter = 
IF(
    MAX('Table'[Category]) IN VALUES(Slicer[Category]),
    1,
    0
)

vjunyantmsft_4-1733885510141.png


And the final output is as below:

vjunyantmsft_5-1733885537343.png

vjunyantmsft_6-1733885545456.png


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

danextian
Super User
Super User

Hi @Cling 

 

Try this:

 

percentage =
DIVIDE (
    [sales],
    CALCULATE ( [sales], ALL ( 'table'[category] ) ) --apply to filter modifier to category so the value remains the same regardless of the filter coming from that column
)


or

percentage =
DIVIDE (
    SUM ( 'table'[amount] ),
    CALCULATE ( SUM ( 'table'[amount] ), ALL ( 'table'[category] ) ) --apply to filter modifier to category so the value remains the same regardless of the filter coming from that column
)

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Helpful resources

Announcements
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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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