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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

Set up a slicer to filter numbers in different columns in Matrix

Hi,

 

I built up a Matrix in power bi. Like this one: 

 

CustomerArea 1Area 2Area 3
Customer 190000 210833
Customer 278000942299272
Customer 3109982345531000
Customer 44567 178078
Customer 5  117446
Customer 6 157835 
Customer 7 141947 
Customer 8  136120
Customer 9120431014 
Customer 10374 4490

 

I want to set up a slicer for 3 areas to be able to sort data in different columns. For example, I choose Area 1, then the whole table will be sorted by descending order of numbers in Area 1 column. 

 

Is that doable in power bi? 

1 ACCEPTED SOLUTION
jdbuchanan71
Super User
Super User

Hello @Anonymous 

You can do what you are looking for, you will just need an extra table and some additional measures.  I assume your matrix is set up with customer on the rows and area on the columns with an amount in the values.  We will have to change that a bit to fit the sort measure in but it's not too bad.

 

First we need a table of the areas.

Area Table = 
DATATABLE(
    "Area",STRING,
    {
        {"Area 1"},
        {"Area 2"},
        {"Area 3"}
    }
)

Then we have a measure to sum the amount and a measure for each of the areas.

Total Amount = SUM ( YourTable[Amount] )
Area 1 Amount = CALCULATE ( [Total Amount], KEEPFILTERS ( YourTable[Area] = "Area 1" ) )
Area 2 Amount = CALCULATE ( [Total Amount], KEEPFILTERS ( YourTable[Area] = "Area 2" ) )
Area 3 Amount = CALCULATE ( [Total Amount], KEEPFILTERS ( YourTable[Area] = "Area 3" ) )

Then the sorting measure that will read the slicer we put over the top of the Area table.

Sort Measure = 
VAR SelectedArea = SELECTEDVALUE ( 'Area Table'[Area], "Area 1" )
RETURN
SWITCH (
    TRUE (),
    SelectedArea = "Area 1", [Area 1 Amount],
    SelectedArea = "Area 2", [Area 2 Amount],
    SelectedArea = "Area 3", [Area 3 Amount]
)

You make the slicer on area and add the 4 measures into your matrix then set the sort on the matrix to be by [Sort Measure]

customersort.jpg

Once you get it working the way you want you can set the [Sort measure] column to be so narrow you can't see it. 

I would set the slicer to be single select only but in my sorting measure I did set the default to use Area 1.  If the user selects 2 areas to sort by the measure will not know which to use so it will default back to Area 1.  Just something to be aware of.

I have attached my sample .pbix file for you to take a look at.

 

 

View solution in original post

2 REPLIES 2
Greg_Deckler
Community Champion
Community Champion

Yes, but you will likely need to create a measure that does a RANKX or returns the value from Area1, Area2 and Area3 based upon the measure selection. You would add that to your matrix visualization and hide the column by turning off word wrap and shrinking it. Then, you could sort the matrix visual by that measure. 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
jdbuchanan71
Super User
Super User

Hello @Anonymous 

You can do what you are looking for, you will just need an extra table and some additional measures.  I assume your matrix is set up with customer on the rows and area on the columns with an amount in the values.  We will have to change that a bit to fit the sort measure in but it's not too bad.

 

First we need a table of the areas.

Area Table = 
DATATABLE(
    "Area",STRING,
    {
        {"Area 1"},
        {"Area 2"},
        {"Area 3"}
    }
)

Then we have a measure to sum the amount and a measure for each of the areas.

Total Amount = SUM ( YourTable[Amount] )
Area 1 Amount = CALCULATE ( [Total Amount], KEEPFILTERS ( YourTable[Area] = "Area 1" ) )
Area 2 Amount = CALCULATE ( [Total Amount], KEEPFILTERS ( YourTable[Area] = "Area 2" ) )
Area 3 Amount = CALCULATE ( [Total Amount], KEEPFILTERS ( YourTable[Area] = "Area 3" ) )

Then the sorting measure that will read the slicer we put over the top of the Area table.

Sort Measure = 
VAR SelectedArea = SELECTEDVALUE ( 'Area Table'[Area], "Area 1" )
RETURN
SWITCH (
    TRUE (),
    SelectedArea = "Area 1", [Area 1 Amount],
    SelectedArea = "Area 2", [Area 2 Amount],
    SelectedArea = "Area 3", [Area 3 Amount]
)

You make the slicer on area and add the 4 measures into your matrix then set the sort on the matrix to be by [Sort Measure]

customersort.jpg

Once you get it working the way you want you can set the [Sort measure] column to be so narrow you can't see it. 

I would set the slicer to be single select only but in my sorting measure I did set the default to use Area 1.  If the user selects 2 areas to sort by the measure will not know which to use so it will default back to Area 1.  Just something to be aware of.

I have attached my sample .pbix file for you to take a look at.

 

 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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.