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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
Dimitris_Kats
Helper V
Helper V

Filter a bar chart based on selected matrix cell

Hi dear members.

I need your help.

I have a matrix with categories in the rows and multiple measures in the values.

For example in the rows I have:

Category 1

Category 2

Category 3

And in the columns:

Measure 1

Measure 2

Measure 3

I want to create a bar chart next to the matrix enabling users to select a specific cell(for example Measure 3, category 1) and display only that measure to the bar chart. Currently the bar chart display all measures for the selected row.

Any idea how to filter not only the rows but the .measure as well??

 

Thank you so much 

 

1 ACCEPTED SOLUTION

Let's slightly modify the expression of the measure, pls try again.

 

xifeng_L_0-1715438051830.png

 

xifeng_L_1-1715438073620.png

 

Use of Bar Chart = 
IF(COUNTROWS(ALLSELECTED(ColumnTable[Item]))>1,
    CALCULATE(
        [AutoIndicator],
        KEEPFILTERS('ColumnTable'[Item]="Measure1"),
        KEEPFILTERS('Fact'[Category]="Category1")
    ),
    [AutoIndicator]
)

 

View solution in original post

11 REPLIES 11
Dimitris_Kats
Helper V
Helper V

@xifeng_L 

The solution has worked perfectly. The only problem is that I can't use conditional formatting to the bar chart. I want to highlight the bar with max value but no matter what I try it's be overwritten 😞

Any idea how to solve it?

Sorry, I have no idea about this. Because after using the legend field, it is not possible to continue with the conditional formatting feature.

No worries. Thank you very much for your help 

xifeng_L
Solution Sage
Solution Sage

Hi @Dimitris_Kats ,

 

Chart interaction can only pass filters for dimension fields to other objects. So, it is necessary to use the column labels of the matrix to achieve filter passing. 

 

But if the column labels of the matrix are used, only one measure can be added, so this measure needs to be able to calculate different indicators based on different column label items.

 

The Solution as follow:

 

#1. Create an auxiliary table to use as a matrix column label. Such as:

 

xifeng_L_0-1715412306294.png

//New Table Expression

ColumnTable = 
DATATABLE(
    "Item",STRING,
    "Index",INTEGER,
    {
        {"Measure1",1},
        {"Measure2",2},
        {"Measure3",3}
    }
)

 

#2. Create a dynamic measure that can calculate different indicators based on different column labels.

 

//Measure Expression

AutoIndicator = 
VAR CurIndicator = SELECTEDVALUE('ColumnTable'[Item])
RETURN
SWITCH(
    CurIndicator,
    "Measure1",[Measure1],
    "Measure2",[Measure2],
    "Measure3",[Measure3]
)

 

#3. Place the measure or column label fields created above into matrices and bar charts.

 

xifeng_L_1-1715412660894.png

xifeng_L_2-1715412690885.png

 

#4. Edit interaction settings to filter.

 

xifeng_L_3-1715412799587.png

 

After completing the above settings, you can meet your needs. Such as:

 

#Default

xifeng_L_5-1715413031252.png

 

# Selected

xifeng_L_4-1715412994297.png

 

 

Did I answer your question? If yes, pls mark my post as a solution and appreciate your Kudos !

 

Thank you~

 

 

 

Thank you so much @xifeng_L  for your time and help. Is it possible to share with me the pbix file?? 

It's a little hard for me to follow your instructions based on the images.

Thank you very much 🙏 

This is great. Thank you so much.

I was wondering if it is possible when there isn't selected any cell to display only one measure instead of all measures??

For example by default the bar chart to display measure 1 if no cell is selected.

I hope this isn't a crazy request 🙈

Sure, it can be achieve.

 

You can create a new measure and use for bar chart. Pls refer to follow pic:

 

xifeng_L_0-1715436276505.png

Use of Bar Chart = 
IF(COUNTROWS(ALLSELECTED(ColumnTable[Item]))>1,
    CALCULATE([AutoIndicator],KEEPFILTERS('ColumnTable'[Item]="Measure1")),
    [AutoIndicator]
)

 

Then, when you select any cells, it will display the corresponding indicators.

 

xifeng_L_1-1715436404412.png

 

Did I answer your question? If yes, pls mark my post as a solution and appreciate your Kudos !

 

Thank you~

 

Oh that's amazing!! Thank you so much!!

One last question, I promise 😅

If I want to add in the rows of bar chart instead of the category the region and when no cell is selected in the matrix to display specific category and measure ( for example category 1 and measure 1) but when a cell is selected in the matrix (the matrix remains the same) to filter the bar chart based on the selected cell ( the corresponding category and measure)

I hope I am not asking for too much.

I want to thank you very much for your help. I really appreciate that 🙏 

Let's slightly modify the expression of the measure, pls try again.

 

xifeng_L_0-1715438051830.png

 

xifeng_L_1-1715438073620.png

 

Use of Bar Chart = 
IF(COUNTROWS(ALLSELECTED(ColumnTable[Item]))>1,
    CALCULATE(
        [AutoIndicator],
        KEEPFILTERS('ColumnTable'[Item]="Measure1"),
        KEEPFILTERS('Fact'[Category]="Category1")
    ),
    [AutoIndicator]
)

 

This is amazing!!! It worked perfectly!!!

Thank you so so much 😊 

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

Check out the June 2024 Power BI update to learn about new features.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.