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

Join 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.

Reply
Lumc88
Frequent Visitor

Distinct count on more than one column for unpivoted table

 I have unpivoted a table of survey data becuase the respondents could select more than one of several options for one of the questions.  I am now trying to do a distinct count, however, it only counts distinct Staff IDs, I need a distinct count based on the 'Staff ID' and 'Question 2' i.e. 2 staff members responded 'Yes' 

 

Staff IDQuestion 1Question 2
1Test 1Yes
1Test 2Yes
1Test 3Yes
2Test 4Yes
2Test 5Yes
2Test 6Yes
3Test 7No 
3Test 8No 
3Test 9No 

 

Would be very grateful if someone could advise how best to do this!

 

Thank you!

2 ACCEPTED SOLUTIONS
Daniel29195
Super User
Super User

@Lumc88 

 

calculate( distinctcount( tbl_name[ staff ID ] , tbl_name[Question 2] = "Yes" ) 

 

let me know if this helps .

 

 

 

If my answer helped sort things out for you, i would appreciate a thumbs up 👍 and mark it as the solution
It makes a difference and might help someone else too. Thanks for spreading the good vibes! 🤠

View solution in original post

@Lumc88 

the code written by quick measure  is equal to : calculate( distinctcount( tbl_name[ staff ID ] , tbl_name[Question 2] = "Yes" ) 

 

did you change the tbl_name to your table name ? 

 

 

View solution in original post

4 REPLIES 4
vanessafvg
Super User
Super User

then do a distinct value on  a concatenation of the fields  so concatenate the fields into one and do a distinct count them.





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




Daniel29195
Super User
Super User

@Lumc88 

 

calculate( distinctcount( tbl_name[ staff ID ] , tbl_name[Question 2] = "Yes" ) 

 

let me know if this helps .

 

 

 

If my answer helped sort things out for you, i would appreciate a thumbs up 👍 and mark it as the solution
It makes a difference and might help someone else too. Thanks for spreading the good vibes! 🤠

Thanks for the suggestions.

 

I couldn't get either to work for me, however, I figured out a solution using a quick measure as below;

 

Returners =
CALCULATE(
    DISTINCTCOUNT('Leavers New'[StaffID]),
    'Leavers New'[Question2]
        IN { "Yes" }
)

@Lumc88 

the code written by quick measure  is equal to : calculate( distinctcount( tbl_name[ staff ID ] , tbl_name[Question 2] = "Yes" ) 

 

did you change the tbl_name to your table name ? 

 

 

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.