Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hello,
I have test data like this:
NOTE: you can download pbix file here.
Scenario:
Users are being interviewed and it is possible that the same user gets interviewed multiple times during a month.
Users are providing Yes/No answers (represented by 1 and 0, respectively) in a questionnaire that has multiple questions.
Requirement:
Matrix should display all results for interviews that occured in the selected month, regardless how many questionnaires were submitted.
However, in TOTAL column we need to count how many users answered with Yes on certain question, but using only the latest response. (If there are muliple answers by same users, previos responses should be ignored in the calculation).
So, in the example below, expected Total in the first row should be 2 and in the second row it should be 0.
Please help!
Solved! Go to Solution.
Hi, @nenadpekec
Please check the below picture and the sample pbix file's link down below.
Hi, My name is Jihwan Kim.
If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.
Linkedin: linkedin.com/in/jihwankim1975/
Twitter: twitter.com/Jihwan_JHKIM
Hi, @nenadpekec
Please check the below picture and the sample pbix file's link down below.
Hi, My name is Jihwan Kim.
If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.
Linkedin: linkedin.com/in/jihwankim1975/
Twitter: twitter.com/Jihwan_JHKIM
Thank you, very much!
// This measure shows how many users
// answered 'Yes' to at least one question
// (and this 'Yes' must be the latest
// answer).
// **Everything is relative to
// the current context, of course.**
// So, if you slice by Question, User and
// Date, you'll replicate the matrix you've
// shown but also the totals will be according
// to your definition.
[Your Measure] =
// We want to count the users whose
// latest answer is 'Yes' to at least
// one question in scope.
var UserQuestionWithLatestResponseDate =
ADDCOLUMNS(
SUMMARIZE(
T,
T[User],
T[Question]
),
"@LatestResponseDate",
CALCULATE( MAX( T[Date] ) )
)
var CountOfUsersWithAtLeastOneQWithYesA =
CALCULATE(
DISTINCTCOUNT( T[User] ),
TREATAS(
UserQuestionWithLatestResponseDate,
T[User],
T[Question],
T[Date]
),
KEEPFILTERS( T[Value] = 1 )
)
return
CountOfUsersWithAtLeastOneQWithYesA + 0
It wolud be equally as easy to write a measure which would count users with all questions (in scope) answered with "Yes." And if you sliced such a measure the way the matrix is, the outcome would be the same as for the measure above.
Please bear in mind the definition of the measure when you view the measure's values. The measure is correct and does what you want but you have to read well its description to realize it's doing what it's supposed to. One last screenshot:
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
10 | |
9 | |
8 | |
7 | |
6 |
User | Count |
---|---|
14 | |
13 | |
11 | |
9 | |
8 |