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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
szoradam
Regular Visitor

Filter on visuals based on selected value but different logic

Hello,

 

I have a data set of customer satisfaction surveys where data is organized according to the below picture. Answer headers contains info about 1 fill of the survey, answer details holding the per question data.

We are showing every question of the survey in a separate visual, using the answer__details / Value_or_OptionHU field.

I would like to achive a filtering where user clicks on some value of a visual (i.e. one slice of a pie chart) then all other visuals/questions on the page are being filtered to show answers where the users gave the same answer for the selected corresponding question.

Example:
Question 1: How would you rate us? 
Options: 1,2,3,4,5
If i click on the pie chart's slice that shows the 5 ratings, the other visuals of other questions should show the answers (of other questions) where the answer of the same user for the 1st question was 5.

Here are my tables: 

szoradam_0-1740747463142.png


My approach was to find all AnswerIDs where the same answer for the same question was given and filter the visuals of the page to those, but cannot make it work....

FilteredAnswerIDs =
VAR SelectedQuestion = SELECTEDVALUE(answer__details[QuestionID])
VAR SelectedValue = SELECTEDVALUE(answer__details[Value_Or_OptionHU])

RETURN
CALCULATE(
    DISTINCT(answer__details[AnswerID]),
    answer__details[QuestionID] = SelectedQuestion,
    answer__details[Value_Or_OptionHU] = SelectedValue
)

I would appreaciate any suggestion 🙂
Many thanks!
Adam
3 REPLIES 3
szoradam
Regular Visitor

Sorry if my question was not clear enough.
Probably this code of my measure will be more speachful for you:

CountOfResults = 
VAR mySelectedQuestionID = SELECTEDVALUE(answer__details[QuestionID]) 
VAR mySelectedValue = SELECTEDVALUE(answer__details[Value_Or_OptionHU])

VAR SelectedAnswerIDs = IF (
    NOT(ISBLANK(mySelectedQuestionID)) && NOT(ISBLANK(mySelectedValue)),
    FILTER(
        ALL(answer__details),
        answer__details[QuestionID] = mySelectedQuestionID &&
        answer__details[Value_Or_OptionHU] = mySelectedValue
    ),
    ALL(answer__details)
)

RETURN
    COUNTROWS(
        FILTER(
            ALL('answer__details'), 
            NOT(ISBLANK('answer__details'[value_or_optionhu])) &&
            'answer__details'[AnswerID] IN 
                 SELECTCOLUMNS(SelectedAnswerIDs, "AnswerID", answer__details[AnswerID])
            )
        )


What i would like to achieve is based on the selected values in the context, i get a list of answerIDs (so far it is working), and then I would like to count the rows of my 'answer__details' table where the answerID is in the list of the IDs I previously calculated. Chatgpt is not able to help we are going in circles as suggesting to use selectcolumn(), values(), but cannot manage to get the IDs out of my variable in a proper way to be able to use with the "IN" condition.

AilleryO
Memorable Member
Memorable Member

Hi,

 

Could it be related with your filters, it shloud be AND, isnt't it ?, so :

answer__details[QuestionID] = SelectedQuestion &&
    answer__details[Value_Or_OptionHU] = SelectedValue
With a comma you get the equivalent of OR.
Does it solve your problem ?
lbendlin
Super User
Super User

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.

Need help uploading data? https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...
Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.