Forum Discussion
Issue with DAX Measure for Filtering Multiple Visuals Based on Slicer Selection in Power BI
Hello everyone,
I'm experiencing difficulties with a DAX measure in Power BI that is intended to filter four visuals based on selected experiments from a slicer. Despite multiple attempts, the visuals are not behaving as expected.
Context:
- Data Source: I have a table (Sheet1) that contains data on various experiments.
- Objective: I want to display the same feature in the same phase across four different plots, each corresponding to one of the selected experiments from a slicer.
- Setup:
- I have a slicer based on Sheet1[Experiment] that allows multiple selections.
- I have four visuals (plots) where each should display data for one of the selected experiments.
I created measures to identify the first, second, third, and fourth selected experiments:
FirstSelectedExperiment =
IF(
COUNTROWS(ALLSELECTED(Sheet1[Experiment])) >= 1,
INDEX(
1,
ALLSELECTED(Sheet1[Experiment]),
ORDERBY(Sheet1[Experiment], ASC)
),
BLANK()
)
IsFirstExperimentSelected =
IF(
HASONEVALUE(Sheet1[Experiment]) &&
SELECTEDVALUE(Sheet1[Experiment]) = [FirstSelectedExperiment],
1,
0
)
SecondSelectedExperiment =
IF(
COUNTROWS(ALLSELECTED(Sheet1[Experiment])) >= 2,
INDEX(
2,
ALLSELECTED(Sheet1[Experiment]),
ORDERBY(Sheet1[Experiment], ASC)
),
BLANK()
)
IsSecondExperimentSelected =
IF(
HASONEVALUE(Sheet1[Experiment]) &&
SELECTEDVALUE(Sheet1[Experiment]) = [SecondSelectedExperiment],
1,
0
)
ThirdSelectedExperiment =
IF(
COUNTROWS(ALLSELECTED(Sheet1[Experiment])) >= 3,
INDEX(
3,
ALLSELECTED(Sheet1[Experiment]),
ORDERBY(Sheet1[Experiment], ASC)
),
BLANK()
)
IsThirdExperimentSelected =
IF(
HASONEVALUE(Sheet1[Experiment]) &&
SELECTEDVALUE(Sheet1[Experiment]) = [ThirdSelectedExperiment],
1,
0
)
FourthSelectedExperiment =
IF(
COUNTROWS(ALLSELECTED(Sheet1[Experiment])) >= 4,
INDEX(
4,
ALLSELECTED(Sheet1[Experiment]),
ORDERBY(Sheet1[Experiment], ASC)
),
BLANK()
)
IsFourthExperimentSelected =
IF(
HASONEVALUE(Sheet1[Experiment]) &&
SELECTEDVALUE(Sheet1[Experiment]) = [FourthSelectedExperiment],
1,
0
)
Since I am still beginning with PowerBi, I might have overestimated it and I am loosing time now. Again I do not want to configure each visual manually butr I want the plots to change based on the selected experiments in the Experiment Slicer. For Example:
Plot one gets Experiment 1 relevant data, Plot 2 gets Experiment 2 relevant data, etc.. And all this in the same dashboard by dynamically selecting multiple experiments from a slicer.
| Experiment,Phase_Run,Speed,MeasurementValue |
| Experiment 1,Phase1_Run1,10,0.75 |
| Experiment 1,Phase1_Run1,20,0.78 |
| Experiment 1,Phase2_Run1,10,0.77 |
| Experiment 1,Phase2_Run1,80,0.92 |
| Experiment 1,Phase3_Run1,10,0.79 |
| Experiment 1,Phase3_Run1,20,0.81 |
| Experiment 1,Phase3_Run1,30,0.83 |
| Experiment 1,Phase3_Run1,40,0.85 |
| Experiment 1,Phase3_Run1,50,0.87 |
| Experiment 1,Phase3_Run1,60,0.89 |
| Experiment 1,Phase3_Run1,70,0.91 |
| Experiment 1,Phase3_Run1,80,0.93 |
| Experiment 1,Phase3_Run1,90,0.95 |
| Experiment 1,Phase3_Run1,100,0.97 |
| Experiment 1,Phase3_Run2,10,0.80 |
| Experiment 1,Phase3_Run2,20,0.82 |
| Experiment 1,Phase3_Run2,30,0.84 |
| Experiment 1,Phase3_Run2,40,0.86 |
| Experiment 2,Phase1_Run1,10,0.74 |
| Experiment 2,Phase1_Run1,20,0.76 |
| Experiment 2,Phase1_Run1,30,0.78 |
| Experiment 2,Phase1_Run1,40,0.80 |
| Experiment 2,Phase2_Run1,20,0.78 |
| Experiment 2,Phase2_Run1,30,0.80 |
| Experiment 3,Phase1_Run1,100,0.96 |
| Experiment 3,Phase1_Run2,10,0.79 |
| Experiment 3,Phase1_Run2,20,0.81 |
| Experiment 3,Phase1_Run2,30,0.83 |
| Experiment 3,Phase1_Run2,40,0.85 |
You may want to look into Small Multiples. There may not be a need for these measures as visual filters.
Please show the expected outcome based on the sample data you provided.
4 Replies
- lbendlinSuper User
You may want to look into Small Multiples. There may not be a need for these measures as visual filters.
Please show the expected outcome based on the sample data you provided.- Spearitch502New Member
It worked fine ! Using Small multiples solved the issue. I was counting too much on GPT and Claude AI, but neither of them provided a suitable answer. At least both went for a complicated DAX based approach!
- AnonymousNot applicable
Your solution is great lbendlin
Hi, Spearitch502
Super user answers your questions, and you get answers from them. You can mark his reply as a solution so that others in the community can quickly find an answer if they have a similar problem.
Your cooperation will work with us to promote the development of the community. Thank you again for your cooperation!Best Regards
Jianpeng Li