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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
sharpedogs
Advocate II
Advocate II

If Statements not working properly, please have a look.

I can't use a calcualted column in PowerQuery because I haveto many steps.

 

Here is a sample of my column DAX. When i put this in play the second || doesn't seem to get picked up correctly. It only recognizes the first ||. Is there a better way to do this, or is my syntext incorrect?

 

Test column = 
IF('Table1'[Workflow Stage] = "In Progress"
&& 'Table1'[Finding Stage] = "Remediation In Progress"
|| 'Table1'[Workflow Status_2] = "Action Plan in Progress​"
|| 'Table1'[Workflow Status_2] = "Re-Baseline in Progress",
"Submit Remediation Plan​",
BLANK()
)
1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

&& is stronger than ||

Your statement translates to 

 

Test column = 
IF(('Table1'[Workflow Stage] = "In Progress"
&& 'Table1'[Finding Stage] = "Remediation In Progress")
|| 'Table1'[Workflow Status_2] = "Action Plan in Progress​"
|| 'Table1'[Workflow Status_2] = "Re-Baseline in Progress",
"Submit Remediation Plan​",
BLANK()
)
 
You could also make the rules more clear like this:
Test column = 
SWITCH(TRUE(),'Table1'[Workflow Stage] = "In Progress" && 'Table1'[Finding Stage] = "Remediation In Progress","Submit Remediation Plan​",
'Table1'[Workflow Status_2] IN {"Action Plan in Progress​","Re-Baseline in Progress"},"Submit Remediation Plan​",
BLANK()
)

 

Is that your intended logic?

View solution in original post

7 REPLIES 7
lbendlin
Super User
Super User

&& is stronger than ||

Your statement translates to 

 

Test column = 
IF(('Table1'[Workflow Stage] = "In Progress"
&& 'Table1'[Finding Stage] = "Remediation In Progress")
|| 'Table1'[Workflow Status_2] = "Action Plan in Progress​"
|| 'Table1'[Workflow Status_2] = "Re-Baseline in Progress",
"Submit Remediation Plan​",
BLANK()
)
 
You could also make the rules more clear like this:
Test column = 
SWITCH(TRUE(),'Table1'[Workflow Stage] = "In Progress" && 'Table1'[Finding Stage] = "Remediation In Progress","Submit Remediation Plan​",
'Table1'[Workflow Status_2] IN {"Action Plan in Progress​","Re-Baseline in Progress"},"Submit Remediation Plan​",
BLANK()
)

 

Is that your intended logic?

SPOT ON..... this works perfect.. the IN function is a great way of making the logic easyier to follow...
 
 
You could also make the rules more clear like this:
Test column = 
SWITCH(TRUE(),'Table1'[Workflow Stage] = "In Progress" && 'Table1'[Finding Stage] = "Remediation In Progress","Submit Remediation Plan​",
'Table1'[Workflow Status_2] IN {"Action Plan in Progress​","Re-Baseline in Progress"},"Submit Remediation Plan​",
BLANK()
)

I think so.... I'll test it in the AM. 

 

 

MattAllington
Community Champion
Community Champion

I'm sure you can use PQ.

 

I think your logical test lacks some structure. Am I correct there are 3 tests, and the first test contains 2 things that must be true?  If so, try wrapping brackets around the first two tests. 

you could also write

Test column = 
SWITCH(TRUE(),
'Table1'[Workflow Stage] = "In Progress"
&& 'Table1'[Finding Stage] = "Remediation In Progress","Submit Remediation Plan​",
'Table1'[Workflow Status_2] = "Action Plan in Progress​","Submit Remediation Plan​",
'Table1'[Workflow Status_2] = "Re-Baseline in Progress","Submit Remediation Plan​",
BLANK()
)


* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.
I will not give you bad advice, even if you unknowingly ask for it.

The logic makes sense in my head, but putting it on paper is a task.. 🙂

I see what you have done, I'm not sure fully how SWITCH works so i'll have to test it with my data set tomorrow. I've spent to much time on it tonight.

 

My logic is as such 

All three things have to be true, the first two tests are exact objects and the third can be either of the two objects. But it has to be one of the Two objects.

 

Test 1  

'Table1'[Workflow Stage] = "In Progress"

 

Test 2

'Table1'[Finding Stage] = "Remediation In Progress"
 
Test 3
'Table1'[Workflow Status_2] = "Action Plan in Progress​" OR "Re-Baseline in Progress"
 
If all three things are met then i give back  "Submit Remediation Plan​". If they are not met then i give back a BLANK.

What do you mean "I'm not sure fully how SWITCH works"? Is it not enough to go to https://dax.guide/switch/ to understand FULLY how it works?

lol....  in case your wondeirng... this community forum exists because sometimes when you read the documentation you don't FULLY understand it....  if you don't FULLY understand that! Then maybe try doing some trolling on facebook instead of our community forum.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.