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

July 28 - August 9 | Final Round of the Power BI Dataviz World Championships. This is 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.

Fabric Community Sticker Design Challenge Barcelona Carousel

Fabric Community Sticker Challenge - Barcelona 2026

If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!

July Power BI Update Carousel

Power BI Monthly Update - July 2026

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

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.

Top Solution Authors