Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
I have survey data , having customer info, it has 50 flag columns having yes/ no values . I have to create a slicer having all these flag column names , such that if I click on a flag letters say HasPro , it should filter all visuals by HasPro=yes.
P.S. I can't really unpivot the data as there are 15columns .
a sample could be
cust no . | survey wave| response date| iscitiezen | has policy | has pro | has premium | has PPU .
All the columns after response date are having yes/ no values.Please note : these columns are not mutually exclusive so I can't create a single calculated column , that can be further used in a slicer.
Thanks , for the help team , however , my use case is a bit different and I had confiedential data in my data set do I was unable to Provide the sample . I tried all the above solutions , all did part ofthe job , but my requirement is a bit diffferent .
Hi @Radz2707 ,
As you mentioned that, you data is confidential. you can't able to share sample data. Based on your inputs , i have created sample data.
Please follow below steps.
1. Created sample data based on your column headers. please refer snap.
2. Created disconnected table, to reprsent the flag names in slicer based on below DAX code.
If this information is helpful, please “Accept it as a solution” and give a "kudos" to assist other community members in resolving similar issues more efficiently.
Thank you.
Hi @Radz2707 ,
Thank you for reaching out to the Microsoft Community Forum.
Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
Do not include sensitive information. Do not include anything that is unrelated to the issue or question.
Please show the expected outcome based on the sample data you provided.
Thank you
Hi @Radz2707 ,
We haven’t heard from you on the last response and was just checking back to see , please provide sample data And, if you have any further query do let us know.
Thank you.
Hi @Radz2707
What does this mean?
P.S. I can't really unpivot the data as there are 15columns .
It would be easier for anyone to provide a more feasible solution had you provided a sample data which doesn't have to be confidential but actually represents the actual data, and your expected result from that. Ensure that we can easily copy-paste it.
Hi Radz2707,
I tried to implement a solution based on your original post. Please check the below pbix file.
creating a filter based on columns.pbix
If this reply helped solve your problem, please consider clicking "Accept as Solution" so others can benefit too. And if you found it useful, a quick "Kudos" is always appreciated, thanks!
Best Regards,
Maruthi
could you pls provide some sample data (not only the headers) and the expected output?
Proud to be a Super User!
Hi,
I do not understand what you mean by "I can't really unpivot the data as there are 15columns"? Why can you not unpivot?
Generated by AI
🛠️ Solution Outline (Without Unpivoting)
Manually define a table listing all your flag column names.
Option 1: Use DAX to create it
FlagSelector =
DATATABLE(
"FlagName", STRING,
{
{"IsCitizen"},
{"HasPolicy"},
{"HasPro"},
{"HasPremium"},
{"HasPPU"}
}
)
Or create it in Power Query if you prefer.
Here’s the trick: write a measure that checks the selected flag and filters rows accordingly.
SelectedFlagFilter =
VAR SelectedFlag = SELECTEDVALUE(FlagSelector[FlagName])
RETURN
SWITCH(
TRUE(),
SelectedFlag = "IsCitizen", CALCULATE(COUNTROWS(SurveyData), SurveyData[IsCitizen] = "Yes"),
SelectedFlag = "HasPolicy", CALCULATE(COUNTROWS(SurveyData), SurveyData[HasPolicy] = "Yes"),
SelectedFlag = "HasPro", CALCULATE(COUNTROWS(SurveyData), SurveyData[HasPro] = "Yes"),
SelectedFlag = "HasPremium", CALCULATE(COUNTROWS(SurveyData), SurveyData[HasPremium] = "Yes"),
SelectedFlag = "HasPPU", CALCULATE(COUNTROWS(SurveyData), SurveyData[HasPPU] = "Yes"),
BLANK()
)
That measure gives you dynamic results — you can also use a version returning 1/0 (TRUE/FALSE) to use as a visual filter.
To filter visuals based on the selected flag:
ShowRow =
VAR SelectedFlag = SELECTEDVALUE(FlagSelector[FlagName])
RETURN
SWITCH(
TRUE(),
SelectedFlag = "IsCitizen", SurveyData[IsCitizen] = "Yes",
SelectedFlag = "HasPolicy", SurveyData[HasPolicy] = "Yes",
SelectedFlag = "HasPro", SurveyData[HasPro] = "Yes",
SelectedFlag = "HasPremium", SurveyData[HasPremium] = "Yes",
SelectedFlag = "HasPPU", SurveyData[HasPPU] = "Yes",
TRUE()
)
Then, drag this measure to the filter pane of your visuals, and set it to TRUE.
🔄 Result
Now, your slicer shows:
IsCitizen | HasPolicy | HasPro | HasPremium | HasPPU
And selecting, say, HasPro dynamically filters your visuals to only show customers where HasPro = "Yes" — without unpivoting or restructuring your data model.
⚠️ Notes
User | Count |
---|---|
84 | |
80 | |
70 | |
47 | |
43 |
User | Count |
---|---|
108 | |
54 | |
50 | |
40 | |
40 |