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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
matthewtjy
Helper I
Helper I

How to count number of yes/no from two separate columns in a table for pie chart?

WorkplaceDoes workplace have a water cooler?Does the workplace have a microwave?
AYesNo

B

  
CYesYes
DNoYes
E  
FNoNo
GYesNo
HNoNo
IYesYes
J  

 

So what I would like to achieve is have a pie chart visualisation that shows out of these 10 workplaces, how many have a "YES" in either having a water cooler or microwave.

 

Those workplaces without values were closed down.

 

So the pie chart should show 50% Yes (from A, C, D, G, I because they have "YES" in either columns) and 50% No (from B, E, F, H, J because they have "NO" in both columns/no values at all).

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @matthewtjy ,

 

If there are many other columns like [Does workplace have a water cooler?]  or [Does the workplace have a microwave?] ,please kindly refer to @Tahreem24 's method by pivoting the original table.


Or if there are just the two columns, please add a column with "Yes" or "No" flag:

Yes or No = 
var _combine= COMBINEVALUES("," , [Does workplace have a water cooler?] ,[Does the workplace have a microwave?])
return IF(CONTAINSSTRING(_combine,"Yes"),"Yes","No")

Then create Pie visual:

Eyelyn9_0-1648535161022.png

 

 

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

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi @matthewtjy ,

 

If there are many other columns like [Does workplace have a water cooler?]  or [Does the workplace have a microwave?] ,please kindly refer to @Tahreem24 's method by pivoting the original table.


Or if there are just the two columns, please add a column with "Yes" or "No" flag:

Yes or No = 
var _combine= COMBINEVALUES("," , [Does workplace have a water cooler?] ,[Does the workplace have a microwave?])
return IF(CONTAINSSTRING(_combine,"Yes"),"Yes","No")

Then create Pie visual:

Eyelyn9_0-1648535161022.png

 

 

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

Tahreem24
Super User
Super User

@matthewtjy try this:

Step1 : Go to power query editor and select Microwave and watercooler column then click on unpivot column under Transform tab.

Step 2: Close and Apply

Step 3: Create a measure like this:

Measure =  CALCULATE(count(WorkspaceTable[Workplace]),WorkspaceTable[Value]="Yes")
Step 4: Then take a pie chart and take this measure under values field and Attribute under Details field.
 
Capture.JPG
 
Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard
amitchandak
Super User
Super User

@matthewtjy , Create a table with Two values yes and no. Then join it with both columns. One join will be inactive, that you can activate using userelationship  Then you can have measure

 

Count(Table[Workplace]) +calculate(Count(Table[Workplace]) ,USERELATIONSHIP(dim[Yes/No],Table[Does the workplace have a microwave?]) )

 

https://radacad.com/userelationship-or-role-playing-dimension-dealing-with-inactive-relationships-in...

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi I'm sorry but how do i go about to create a table with Two values yes and no. Then join it with both columns?

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

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 community update carousel

Fabric Community Update - June 2025

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