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
fyrworx
Frequent Visitor

Percentage of boolean/categorical data split over periods

Hi,

 

I am struggling to wrap my head around producing gauges based on data that is either boolean or categorical.

 

I have data over a month, with a yes or no answer - currently 1 for yes 0 for no.

I want to see the % of "yes" answers over the month on one guage and then the % of "yes" answers for each week of the month on the other guages.

 

This should be simple enough but I can't seem to get the measures down. If I could add a slicer to show the the percentage of a selection, that would be great too, ie make a selection of a few dates and see the resulting "yes" percentage.

 

Thanks in advance.

1 ACCEPTED SOLUTION
v-ljerr-msft
Microsoft Employee
Microsoft Employee

Hi @fyrworx,

 

According to your description, I have made a sample for your reference.

 

I assume you have a table called "MyTestTable" like below.

t1.PNG

Then you should be able to use the formula below to create a measure called "% of yes" and show it on the report according to the selection of the Slicer.

% of yes =
CALCULATE ( COUNTROWS ( MyTestTable ), MyTestTable[Answer] = 1 )
    / CALCULATE ( COUNTROWS ( MyTestTable ) )

report.PNG

Regards

View solution in original post

2 REPLIES 2
v-ljerr-msft
Microsoft Employee
Microsoft Employee

Hi @fyrworx,

 

According to your description, I have made a sample for your reference.

 

I assume you have a table called "MyTestTable" like below.

t1.PNG

Then you should be able to use the formula below to create a measure called "% of yes" and show it on the report according to the selection of the Slicer.

% of yes =
CALCULATE ( COUNTROWS ( MyTestTable ), MyTestTable[Answer] = 1 )
    / CALCULATE ( COUNTROWS ( MyTestTable ) )

report.PNG

Regards

Thank you! 

 

I am very new to DAX, so its just figuring out the correct code for what I need.

 

This is exactly what I need, thanks for the response.

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.