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~