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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
aliciab425
Regular Visitor

Power Query IF and AND Statement with Multiple Conditions

Good evening,

 

I am still new to Power Query and haven’t created many custom formulas. Below is an Excel formula I need assistance recreating in Power Query.

 

  1. This formula is used to determine the comp territory

 

=IF(AND(P3="BLANK1",Q3="BLANK2",R3="BLANK3"),"Investigate",IF(AND(P3=Q3,P3=R3),P3,IF(AND(P3<>"BLANK1",Q3="BLANK2",R3="BLANK3"),P3,IF(AND(P3=R3,Q3="BLANK2"),P3,IF(AND(P3<>R3,P3<>"BLANK1",R3<>"BLANK3",Q3="BLANK2"),"300-Corporate",IF(AND(P3<>"BLANK1",Q3<>"BLANK2",P3<>Q3,R3="BLANK3"),"300-Corporate",IF(AND(P3="BLANK1",Q3<>"BLANK2",R3="BLANK3"),Q3,IF(AND(P3="BLANK1",Q3<>"BLANK2",Q3<>R3),"300-Corporate",IF(AND(P3="BLANK1",Q3="BLANK2",R3<>"BLANK3"),R3,IF(AND(P3<>"BLANK1",Q3<>"BLANK2",R3<>"BLANK3",P3<>Q3,Q3<>R3),"300-Corporate",IF(AND(P3="BLANK1",Q3=R3),Q3,IF(AND(P3=Q3,R3="BLANK3"),P3,IF(AND(P3=Q3,P3<>R3,R3<>"BLANK3"),"300-Corporate",IF(AND(P3<>"BLANK1",P3<>Q3,Q3=R3),"300-Corporate","ERROR"))))))))))))))

 

aliciab425_0-1642474214965.png

 

 

Thank you in advance for your assistance.   

1 ACCEPTED SOLUTION
BA_Pete
Super User
Super User

Hi @aliciab425 ,

 

I'm not going to completely rewrite the formula, but here is the structure and terminology you need to do this in Power Query:

if [AST Terr 1] = "BLANK1" and [AST Terr 2] = "BLANK2" and [AST Terr 3] = "BLANK3" then "investigate"
else if [AST Terr 1] = [AST Terr 2] and [AST Terr 1] = [AST Terr 3] then [AST Terr 1]
else if [AST Terr 1] <> "BLANK1" and [AST Terr 2] = "BLANK2" and [AST Terr 3] = "BLANK3" then [AST Terr 1]
else if...
...
else //your escape value here e.g. null, "ERROR" etc.

 

Any logical operators (+, *, <, > etc.) can be used in exactly the same way as in Excel.

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




View solution in original post

2 REPLIES 2
AnkitKukreja
Super User
Super User

Hi! @aliciab425 

 

It would be easy to write the formula if you can share the sample data and expected result.

For Power BI trainings or support dm or reach out to me on LinkedIn.
If my response has successfully addressed your question or concern, I kindly request that you mark this post as resolved. Additionally, if you found my assistance helpful, a thumbs-up would be greatly appreciated.

Thanks,
Ankit Kukreja
www.linkedin.com/in/ankit-kukreja1904
BA_Pete
Super User
Super User

Hi @aliciab425 ,

 

I'm not going to completely rewrite the formula, but here is the structure and terminology you need to do this in Power Query:

if [AST Terr 1] = "BLANK1" and [AST Terr 2] = "BLANK2" and [AST Terr 3] = "BLANK3" then "investigate"
else if [AST Terr 1] = [AST Terr 2] and [AST Terr 1] = [AST Terr 3] then [AST Terr 1]
else if [AST Terr 1] <> "BLANK1" and [AST Terr 2] = "BLANK2" and [AST Terr 3] = "BLANK3" then [AST Terr 1]
else if...
...
else //your escape value here e.g. null, "ERROR" etc.

 

Any logical operators (+, *, <, > etc.) can be used in exactly the same way as in Excel.

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.

Top Solution Authors