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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
Anonymous
Not applicable

How can I find common items for filtering in slicer

Hi,

 

I have survey data like this:

 

Answers:

UserIDSurveyNameResponseIDQuestionDescriptionAnswerText
user1survey1res1_1_1question1A
user1survey1res1_1_1question2A
user1survey1res1_1_1question3B
user1survey1res1_1_2question2B
user1survey2res1_2_1question1B
user1survey2res1_2_1question2C
user2survey1res2_1_1question1A
user2survey1res2_1_1question2C
user2survey2res2_2_1quesrion1B

 

And I have created 2 new table for my cases:

 

Table (7a) = DISTINCT('answers'[QuestionDescription])
Table (7b) = DISTINCT('answers'[SurveyName])

 

What I need is to find common users who responded to the two surveys below and find their distribution based on their answers to the question I chose. I can do this with the formula below.

 

 

 

 

Count of Cohort 7c = 
    VAR __tmpTable1 = 
        CALCULATETABLE(
            GENERATE(
                DISTINCT('answers'[UserID]),
                EXCEPT(
                    DISTINCT('answers'[SurveyName]),
                    CALCULATETABLE(DISTINCT('answers'[SurveyName]))
                )
            ),USERELATIONSHIP(answers[ResponseId],responses[ResponseID]),
            REMOVEFILTERS('answers'[AnswerText])
        )
    VAR __tmpTable2 = SUMMARIZE(__tmpTable1,[UserID])
    VAR __tmpTable3 = EXCEPT(DISTINCT('answers'[UserID]),__tmpTable2)
    VAR __CountMax = COUNTROWS(__tmpTable3)

    VAR __Survey = SELECTCOLUMNS('Table (7b)',"__SurveyName",[SurveyName])
    VAR __Question = SELECTCOLUMNS('Table (7a)',"__QuestionDescription",[QuestionDescription])
    VAR __tmpTable4 = DISTINCT(SELECTCOLUMNS(FILTER('answers',[SurveyName] IN __Survey && [QuestionDescription] IN __Question),"UserID",[UserID]))
    VAR __CountMin = COUNTROWS(__tmpTable4)
    VAR __tmpTable5 = FILTER(__tmpTable4,[UserID] IN __tmpTable3)
    VAR __Count = COUNTROWS(__tmpTable5)
RETURN
    SWITCH(TRUE(),
        ISBLANK(COUNTROWS(__tmpTable4)),BLANK(),
        __CountMin < __Count,__CountMin,
        __Count > __CountMax,__CountMax,
        __Count
    )

 

 

 

 

 
 

Capture.PNG

 

When I select question and 2th surveyName I can find true common users and I see their distribution for answers correctly. But When I select a part of pie chart I can not see true data:

 

Capture1.PNG

 

How can I solve this?

 

10 REPLIES 10
Anonymous
Not applicable

Hi All, Can you help me, I can not still fix it and It is a big problem for me.

 

Best,

Anonymous
Not applicable

Hi There, Do you have any solution about my problem?

 

Best,

v-deddai1-msft
Community Support
Community Support

Hi @Anonymous ,

 

I tried to understand the measure you provided, but there is no [UserID] column in answers table in the sample data you give us. Would you please explain more about your measure?

 

Best Regards,

Dedmon Dai

Anonymous
Not applicable

Hi @v-deddai1-msft ,

 

Yes, I have send our original data and I'm sorry but we dont have UserID in answer table. I generally merge Answers table and Response Table with ResponseID. Then I get answer table like User ID | Response ID | Question | Answer Choice| Answer Text

 

And also we dont have question description in Answer Table so I merge Answer Table and Qestion Table with SQ. and we dont have QuestionChoices in Answer Table so I merge Answer Table and QuestionChoices Table wit SQC. 

 

My last answwer table seems that like this:

_id | ResponseID | UserID | QuestionID | DataExportTag | QuestionDescription | QuestionChoices | Answer Choices | Answer Text | SQ | SQC

 

Then I create measurements on this Answer Table. You can do it as this way. But If you know a more effectve way you can show us and we would be grateful to you

 

Best

Anonymous
Not applicable

Hi @v-deddai1-msft ,

 

You can see my power bi report in there:

 

https://yadi.sk/d/wrWkGRR7ZCmgCQ

 

I try to explain what I need from this report in report.

 

I hope you can help me.

v-deddai1-msft
Community Support
Community Support

Hi @Anonymous ,

 

It depends on the relationship in your data table. Would you please show us sample pbix for reference by onedrive for business if possible? Then we can help you more correctly.

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Best Regards,

Dedmon Dai

Anonymous
Not applicable

Hi @aj1973,

 

Actually, I fixed this problem with adding a new answer table and changing measurement as this:

 

Table (7c) = DISTINCT('answers'[AnswerText])
Count of Cohort 7c = 
    VAR __tmpTable1 = 
        CALCULATETABLE(
            GENERATE(
                DISTINCT('answers'[UserID]),
                EXCEPT(
                    DISTINCT('answers'[SurveyName]),
                    CALCULATETABLE(DISTINCT('answers'[SurveyName]))
                )
            ),
            REMOVEFILTERS('answers'[AnswerText])
        )
    VAR __tmpTable2 = SUMMARIZE(__tmpTable1,[UserID])
    VAR __tmpTable3 = EXCEPT(DISTINCT('answers'[UserID]),__tmpTable2)
    VAR __CountMax = COUNTROWS(__tmpTable3)

    VAR __Survey = SELECTCOLUMNS('Table (7b)',"__SurveyName",[SurveyName])
    VAR __Question = SELECTCOLUMNS('Table (7a)',"__QuestionDescription",[QuestionDescription])
    VAR __AnswerText = SELECTCOLUMNS('Table (7c)',"__AnswerText",[AnswerText])
    VAR __tmpTable4 = DISTINCT(SELECTCOLUMNS(FILTER('answers',[SurveyName] IN __Survey && [QuestionDescription] IN __Question && [AnswerText] IN AnswerText),"UserID",[UserID]))
    VAR __CountMin = COUNTROWS(__tmpTable4)
    VAR __tmpTable5 = FILTER(__tmpTable4,[UserID] IN __tmpTable3)
    VAR __Count = COUNTROWS(__tmpTable5)
RETURN
    SWITCH(TRUE(),
        ISBLANK(COUNTROWS(__tmpTable4)),BLANK(),
        __CountMin < __Count,__CountMin,
        __Count > __CountMax,__CountMax,
        __Count
    )

 

But I see an other problem in this time, when I a new question slicer and a answer pie chart and If I click a part of first pie part, second pie chart doesnt change with it.

 

firatseker_0-1608533147957.png

 

 

 

aj1973
Community Champion
Community Champion

Hi @Anonymous 

Check out the relationship of your tables in the model, change the relationship from single to both.

 

Regards
Amine Jerbi

If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook

aj1973
Community Champion
Community Champion

Hi @Anonymous 

check out the filters of the Pie Chart visual

aj1973_0-1608510897900.png

 

maybe something at odd.

 

Regards
Amine Jerbi

If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook

m3tr01d
Continued Contributor
Continued Contributor

Hello!

Try something like this  with two measures:

NbAnswers = COUNTROWS( 'SurveyResponse' )

MostCommon_Count = 
--Find the answer with the most answers
VAR _TopN = TOPN( 1, VALUES( SurveyResponse[AnswerTex] ), [NbAnswers], DESC )

--Return the number of answers for the Top 1
RETURN
CALCULATE(
    [NbAnswers],
    _TopN
)

 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.