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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

Evaluate IF based on two columns and express in a third

Hello, Finishing up a two week project and excited that this is the last formula I need help with.  The problem is looking at two columns and based on the value, select one of four inputs for the fourth. Any help would be appreciated. Thank you!

 

Target.JPG

 

Here is what I have so far: 

 

IF('Main'[Target Business Area]=Store && 'Main'
[#"Active+Open+Contractor"]<7 then "Below Store" else 0
IF('Main'[Target Business Area]=Store && 'Main'[#"Active+Open+Contractor"]>12 then "Above" else 0
IF('Main'[Target Business Area]=Store && 'Main'[#"Active+Open+Contractor"]=7-12 then "In Target" ELSE IF
('Main'[Target Business Area]=Store && 'Main'


[#"Active+Open+Contractor"]<7 then "Below" else 0
IF('Main'[Target Business Area]=CC Ops && 'Main'[#"Active+Open+Contractor"]>12 then "Above" else 0
IF('Main'[Target Business Area]=CC Ops && 'Main'[#"Active+Open+Contractor"]=7-12 then "In Target" ELSE IF
('Main'[Target Business Area]=SSC && 'Main'

 

[#"Active+Open+Contractor"]<7 then "Below" else 0
IF('Main'[Target Business Area]=SSC && 'Main'[#"Active+Open+Contractor"]>12 then "Above" else 0
IF('Main'[Target Business Area]=SSC && 'Main'[#"Active+Open+Contractor"]=7-12 then "In Target" else 0)))
)

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Thanks everyone. I figured it out by creating 6 additional measures in PBI. Appreciate the help.

View solution in original post

6 REPLIES 6
dax
Community Support
Community Support

Hi @Anonymous , 

Based on your description, I don't understand your logic. So if possible, could you please explain this to me in details?

764.PNG

Best Regards,
Zoe Zhi

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Zoe, Thanks for the question. The [Target Business Area] and [Active+Open+Contractor] are both inputs. Each Target Business Area has its own target range which is why the numbers for "Store", "CC Ops", and "SSC" are different.  Previously the targets were all the same and so I just did the filtering in Power BI, but now with different targets, I need to do it in query as I can't tie variables together in PBI. Hope that helps. 

Add Column... Custom Column

 

Your last target range for SSC is wrong, should say 16+

Anonymous
Not applicable

Thanks everyone. I figured it out by creating 6 additional measures in PBI. Appreciate the help.

lbendlin
Super User
Super User

Power query uses lowercase if ... then ... else and doesn't use braces. It also uses "and"  and "or"  ("&&"  and "||"  are used in DAX)

 

Speaking of DAX - that has a SWITCH () function which would make your logic look much nicer even though behind the scenes it would still do nested ifs.

 

Do you want a Power Query version or a DAX version?

 

 

Anonymous
Not applicable

I'm looking at using it in Power Query as I'll have a dataset that will automatically update. 

 

Will it need to be added as a custom column, or placed in advanced editor? Still learning the differences. Thanks

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.