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
kjartank
Helper II
Helper II

Calculating percentage

Hi

 

I have a problem finding out how to get these percentages to work properly. I have one column with numbers and blanks. What I want to do with it is to calculate how many of the filled values are greater than 0. The easiest way would be to switch everything greater than 0 into "Yes" and everything that is labelled 0 into "No", leaving out all the blanks, so I can put it in a bar chart, counting the percentage of yes and no.

 

The data looks like this.

 

How_many_0-5
0
0
0
0
0
0
0
0
0
0
3
0
0
0
0
0
2
0
0
0
0
0
0
0
0
0
0
0
0
2
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0






0
0
0
1
0
0
0
2
2
0

0













0
0

0
0
0
0
0
0
0
0
0
0
0
0
0
1
0

0
0
0
0
0
0
0

Thanks in advance! 🙂

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi,

 

You could create a calculated column which does exactly what you said:

 

Converted = IF( ISBLANK( Table[How_many_0-5] ), BLANK(), IF( Table[How_many_0-5] = 0, "No", "Yes"))

Then you can create a measure:


Count = COUNTA( Table[Converted] )

 

Or as a percentage:

 

Perc = COUNTA( Table[Converted] ) / Calculate( COUNTA(Table[Converted]), ALL(Table[Converted]) )

 

and make a bar chart of the converted column with values coming from one of the measures.

 

You may need to filter out the blank column from the visual if you don't want to see it on the bar chart. Unsure off the top of my head.

 

Hope this helps,

 

Will

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi,

 

You could create a calculated column which does exactly what you said:

 

Converted = IF( ISBLANK( Table[How_many_0-5] ), BLANK(), IF( Table[How_many_0-5] = 0, "No", "Yes"))

Then you can create a measure:


Count = COUNTA( Table[Converted] )

 

Or as a percentage:

 

Perc = COUNTA( Table[Converted] ) / Calculate( COUNTA(Table[Converted]), ALL(Table[Converted]) )

 

and make a bar chart of the converted column with values coming from one of the measures.

 

You may need to filter out the blank column from the visual if you don't want to see it on the bar chart. Unsure off the top of my head.

 

Hope this helps,

 

Will

This is beautiful! Thanks a lot! 🙂

Anonymous
Not applicable

Fantsatic, glad I could help! 😄

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.