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

COUNT with Text and multiple OR statements

Hi All! I am struggling a little with an equation. Overall I am trying to divide count(column1)/count(respondents) in simple terms but it is turning out to be a little harder than that which is where I would appriciate your help. (Also this is my first time posting so if I am missing any info just let me know and I will provide!)

 

So the behind the scenes of the data is that there is a question being asked and each column is one of the answers to the select all questions. So for example:

What did you enjoy about your stay?

Column 1: The Pool

Column 2: The Food

Column 3: The Staff

Column 4: The Golf Course

Column 5: Nothing 

 

So one reason why we cant just divide by the number of respondents is because there may be a respondent who never got that question and so they shouldn't count in denominator since they never had it. We just want the % of people who selected each option from this survey.

 

So here is some sample data:

respondentcolumn1column2column3column4column5question2
111nullnullnullnull
2null1null1nullnull
3null1nullnullnullYes
4nullnull11nullYes
5nullnullnullnull1null
61111nullnull
7nullnullnullnull1null
8nullnullnullnullnullYes
9nullnullnullnullnullYes

* data is in string(text) format not number format 

 

So what I am currently thinking is 

COUNTA(Column1*) / IF (column1) ="1"  OR (column2) ="1"  OR (column3) ="1"  OR (column4) ="1"  OR (column5) ="1"  THEN count(respondents)

* i would replace this with each column and then put into y-axis field because i want a legend for each of them 

 

But this doesn't work because one, if statement doesn't work with text, and two, i can't do an or statement with more than 2 statements/expressions but that equation is just how my mind is thinking. 

 

Another thing to note is I cant do the sum of the count of each columns because I dont want people who selectd multiple answers count twice because it is a select all that apply question so we want a the % of people that selected that answer not the % of all responses. 

 

I have also tried a switch( true() but i need the OR in there i think.

 

If you have any suggestions or if i left anything out just let me know! thanks!

1 REPLY 1
lbendlin
Super User
Super User

The syntax is a little off.

 

 

DIVIDE(COUNTA(Column1) , IF ( [column1]="1"  || [column2] ="1"  || [column3] ="1"  || [column4] ="1"  || [column5] ="1",count(respondents)),0)

 

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.