Forum Discussion
Filter a bar chart based on selected matrix cell
- 2 years ago
Let's slightly modify the expression of the measure, pls try again.
Use of Bar Chart = IF(COUNTROWS(ALLSELECTED(ColumnTable[Item]))>1, CALCULATE( [AutoIndicator], KEEPFILTERS('ColumnTable'[Item]="Measure1"), KEEPFILTERS('Fact'[Category]="Category1") ), [AutoIndicator] )
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:
//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.
#4. Edit interaction settings to filter.
After completing the above settings, you can meet your needs. Such as:
#Default
# Selected
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 🙏
- xifeng_L2 years ago
Super User
- Dimitris_Kats2 years ago
Helper V
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 🙈
- xifeng_L2 years ago
Super User
Sure, it can be achieve.
You can create a new measure and use for bar chart. Pls refer to follow pic:
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.
Did I answer your question? If yes, pls mark my post as a solution and appreciate your Kudos !
Thank you~