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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
Anonymous
Not applicable

IF, AND , COUNT ROWS and RELATEDTABLE Query Help needed

Beginner at PBI

 

Added a column with below query to get Employee Status

 

Status = if(and(COUNTROWS(RELATEDTABLE('Master Data'))>=1,COUNTROWS(RELATEDTABLE('Collated LB'))>=1),COUNTROWS(RELATEDTABLE('Completers Table'))>=1),"Completer", if(and(COUNTROWS(RELATEDTABLE('Master Data'))>=1,COUNTROWS(RELATEDTABLE('Collated LB'))>=1),COUNTROWS(RELATEDTABLE('Completers Table'))>=0),"Enrolled","Yet to Start"))
 
Not Sure why this does not work. 😞
Sangit_0-1627464316398.png

 

Please advice  

 

1 ACCEPTED SOLUTION

@Anonymous 

change and to &&, pls have a try.

 

Status = if(COUNTROWS(RELATEDTABLE('Master Data'))>=1 && COUNTROWS(RELATEDTABLE('Collated LB'))>=1) && COUNTROWS(RELATEDTABLE('Completers Table'))>=1),"Completer", if(COUNTROWS(RELATEDTABLE('Master Data'))>=1 && COUNTROWS(RELATEDTABLE('Collated LB'))>=1) && COUNTROWS(RELATEDTABLE('Completers Table'))>=0),"Enrolled","Yet to Start"))





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

5 REPLIES 5
Siriwat_Lukin
Helper I
Helper I

Hi @Anonymous,

 

Could you please share example you data and result that you want?

 

Thank you,

ryan_mayu
Super User
Super User

@Anonymous 

AND can only has two conditions. if you have three conditions, it needs to be  and(and(condition1, condition2),condition3)
pls try to use && 




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Anonymous
Not applicable

Hi @ryan_mayu 

 

Can you write it in a query form and show as an example or edit below query

 

Status = if(and(COUNTROWS(RELATEDTABLE('Master Data'))>=1,COUNTROWS(RELATEDTABLE('Collated LB'))>=1),COUNTROWS(RELATEDTABLE('Completers Table'))>=1),"Completer", if(and(COUNTROWS(RELATEDTABLE('Master Data'))>=1,COUNTROWS(RELATEDTABLE('Collated LB'))>=1),COUNTROWS(RELATEDTABLE('Completers Table'))>=0),"Enrolled","Yet to Start"))

@Anonymous 

change and to &&, pls have a try.

 

Status = if(COUNTROWS(RELATEDTABLE('Master Data'))>=1 && COUNTROWS(RELATEDTABLE('Collated LB'))>=1) && COUNTROWS(RELATEDTABLE('Completers Table'))>=1),"Completer", if(COUNTROWS(RELATEDTABLE('Master Data'))>=1 && COUNTROWS(RELATEDTABLE('Collated LB'))>=1) && COUNTROWS(RELATEDTABLE('Completers Table'))>=0),"Enrolled","Yet to Start"))





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Anonymous
Not applicable

WOWW it worked 😃

 

Little change with parenthesis. Below is the updated one

 

Status = if(COUNTROWS(RELATEDTABLE('Master Data'))>=1 && COUNTROWS(RELATEDTABLE('Collated LB'))>=1 && COUNTROWS(RELATEDTABLE('Completers Table'))>=1,"Completer", if(COUNTROWS(RELATEDTABLE('Master Data'))>=1 && COUNTROWS(RELATEDTABLE('Collated LB'))>=1 && COUNTROWS(RELATEDTABLE('Completers Table'))>=0,"Enrolled","Yet to Start"))

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! It's time to submit your entry.

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.