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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

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
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.