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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

AND Filtering in the report

Hi There,

 

I have some table like this:

firatseker_0-1599735522153.png

 

Responses Table:

firatseker_1-1599735586445.png

Answer Table:

firatseker_2-1599735604022.png

 

And the visulations:

firatseker_3-1599735662087.png

My first question is how can I find usercount which has responseID both selected surveyName. So the count of userID must show only 2 (ABC1 and ABC2)

 

And the second question is after I find this 2 user, I want to see their answers distribution for any questiontext in any survey. So I want to click 2 or more surveyname in the slicer, the card must show count of userID entering all selected surveys. And then I select another slicer a survey and question text it show me this users ditribution for this selected questiontext in selected surveyname.

 

Thank you for your helping.

 

Best,

1 ACCEPTED SOLUTION

@Anonymous I looked at this, can't really fathom why that is happening. So, might look deeper but I think this fixes the problem, or at least works around it. PBIX is attached.

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

    VAR __Survey = SELECTCOLUMNS('Table (7b)',"__SurveyName",[SurveyName])
    VAR __Question = SELECTCOLUMNS('Table (7a)',"__QuestionText",[QuestionText])
    VAR __tmpTable4 = DISTINCT(SELECTCOLUMNS(FILTER('Table (7)',[SurveyName] IN __Survey && [QuestionText] 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
    )

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

38 REPLIES 38
Anonymous
Not applicable

Hi @Greg_Deckler 

 

If I add  a new pie chart and I want to see selected users distibution in old pie chart in new pie chart. Is that possible?
So I want to see this output:

firatseker_0-1606998572400.png

 

amitchandak
Super User
Super User

@Anonymous ,

A measure like this

measure =
var _sel = maxx(allselected(Response), Response[Survey Name])
return
countx(filter(summarize(Response, Response[user_id], "_1", distinctcount(Response[Survey_id])),[_1] =2),[user_id])

 

All selected surveys are there with user id

Anonymous
Not applicable

Hi @amitchandak and @Greg_Deckler 

 

Thank you for your responses but my main problem is:

 

firatseker_0-1599740747725.png

Can you help me?

@Anonymous OK, if you used Cohort for your and slicer, you should have a line like this:

 

VAR tmpTable3 = EXCEPT(VALUES(Diagnosis[Patient]),tmpTable2)

You could have your measure perform the logic of instead of returning countrows to only return whatever calculation you want for values (patients) IN tmpTable3 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

@Greg_Deckler I have used this code in Cohort:

firatseker_0-1599804587473.png

 

But In my report:

firatseker_1-1599804648614.png

When I select other SurveyName and Questiontext in there, It shows all entered this survey. But I want to show only this 2 users count in the pie chart.

Capture.PNG

 

 

 

 

 

 

 

 

 

 

 

So, In my report:

 

Untitled.png

@Anonymous Right, so use the same Cohort measure syntax in a new measure but change the RETURN statement to something like:

 

RETURN
  IF(MAX([UserID]) IN __TmpTable3,[Old Measure for Value you want to display in pie chart],BLANK())

 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

@Greg_Deckler What is that mean "Old Measure for Value you want to display in pie chart" I didnt understand?

 

I did it like this but again It show wrong data for me. q3a2text must be 2 in the pie chart.

 

 

Capture.PNG

@Anonymous What was the value you were displaying in your pie chart originally?


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

@Greg_Deckler you can see my previous message, q3a2text is always shown 3 even if I run your sent this code:

RETURN
  IF(MAX([UserID]) IN TmpTable3,[Count of Cohort],BLANK())

But I need q3a2text must be shown 2 because 2 userID answer the question as q3a2text and at the same time they join this two survey.  

Anonymous
Not applicable

Hi @Greg_Deckler  do you have any solution for this?

Best,

@Anonymous Sample data as text that I can copy and paste so I can mock this up or even better, the PBIX file.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Hi @Greg_Deckler 

 

This are the sample data:

 

Answers:

 

ResponseIDQuestionIDQuestionTextAnswerIDAnswerText
XYZ1Q1qtext1q1a1q1a1text
XYZ1Q2qtext2q2a1q2a1text
XYZ1Q3qtext3q3a1q3a2text
XYZ2Q1qtext1q1a2q1a2text
XYZ2Q3qtext3q3a1q3a1text
XYZ3Q1qtext1q1a1q1a1text
XYZ3Q2qtext2q2a2q2a2text
XYZ3Q3qtext3q3a2q3a2text
XYZ4Q1qtext1q1a1q1a1text
XYZ4Q2qtext2q2a1q2a1text
XYZ4Q3qtext3q3a2q3a2text
XYZ5Q1qtext1q1a3q1a3text
XYZ5Q2qtext2q2a1q2a1text
XYZ6Q2qtext2q2a3q2a3text
XYZ6Q3qtext3q3a1q3a1text
XYZ7Q1qtext1q1a2q1a2text
XYZ7Q3qtext3q3a2q3a2text
XYZ8Q1qtext1q1a1q1a1text
XYZ8Q2qtext2q2a2q2a2text
XYZ8Q3qtext3q3a1q3a1text

 

Responses:

 

SurveyIDSurveyNameUserIDResponseID
SV_1234survey1ABC1XYZ1
SV_1234survey1ABC1XYZ2
SV_1234survey1ABC2XYZ3
SV_1234survey1ABC3XYZ4
SV_5678survey2ABC1XYZ5
SV_5678survey2ABC4XYZ6
SV_5678survey2ABC3XYZ7
SV_9821survey3ABC1XYZ8
Anonymous
Not applicable

Hi @Greg_Deckler 

 

Do you have any solution about this?

 

Anonymous
Not applicable

Hi There,

 

It is so important for us. It couldn't be fixed. Can you help us?

 

@Anonymous I mocked this up in the attached PBIX below sig. Page 6. I get 3 because with the slicer settings as shown, ABC1 is in there and ABC2 and ABC3 are also in there. So 3. Not sure what you are looking for but the data clearly says 3.

 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Hi @Greg_Deckler ,

 

As you can see in Page 6, the number of users who entered both surveys is 2 ABC1 and ABC3. You can check it your Table (6a)

 

I want to see this two users' answers' distribution in selected other surveys.

 

In this case I want to see this two users' answers' distribution in survey1 and qtext3.

 

So If I count distinct users for any answers, it has to be max 2 because I have 2 users. I try to explain in a ss:

 

firatseker_0-1600935469645.png

 

@Anonymous OK, still something going on that I am working through but I do have a minor work-a-round operating that seems to do the trick. Same page. PBIX below.

 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

@Greg_Deckler , If I select both survey in second survey filter, yes we see right pie chart. But I want to select both or more survey in first survey filter slicer after I see two users entered this this both surveys then I select one survey in second survey slicer and then I must see this two users distribution for selecting questions' answers. So pie chart must include only two users max for all answers slice of pie.

 

firatseker_0-1600954191838.png

 

@Anonymous I have no idea what you are talking about. What?


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

@Greg_Deckler ,

 

I- I choose two survey and what I want to see is the number of common users participating in both survey

 

II-  I choose any survey from the SurveyName filter below because I want to see the distribution of the two users selected above in the selected survey below.

 

III- I chose a question I wanted in QuestionText because I want to see the distributiın of the answers given by the two users above to the question qtext3 in survey1 on the basis of users.

 

IV- Since I want to see the distribution of the answers given by the common users of the two surveys selected in the first filter to the selected survey in the second filter and the selected question in the third filter, a pie slice here can be at most 2. Because I only have 2 users that meet this criterion: ABC1 and ABC3.

 

firatseker_0-1600957826121.png

I dont know how can I explain more.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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