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
chel4782
Frequent Visitor

Need help with conditional column

I cannot seem to get the last part of this query

 

Excel

=IF([@[PT reporting change]]="after change",[@[PT 2]],IF([@[PT/NPT]]="PT",IF([@activity]="NONOPS",0,[@DURATION]),IF(OR([@operation]="saftey",[@operation]="commute",[@operation]="lunch"),[@DURATION],0)))

 

Power Bi-Power Query

if[PT Reporting Change]="AFTER CHANGE" then [PT2]
else if ([activity]="NONOPS" and [#"PT/NPT"]="PT") then 0
else if ([operation]="safety" or [operation]="commute" or [operation]="lunch") then [DURATION] else ""

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

Here's how your code looks like after playing with it in Powerqueryformatter.com

 

  if [PT Reporting Change] = "AFTER CHANGE" then [PT2]
  else if ([activity] = "NONOPS" and [#"PT/NPT"] = "PT") then 0 
       else if ([operation] = "safety" or [operation] = "commute" or [operation] = "lunch")    then [DURATION]
            else ""

 

Your return values can be [PT2], 0, [Duration], or "" .  That's not really cool.  You want to decide on a column type and then adjust the return values accordingly.

View solution in original post

1 REPLY 1
lbendlin
Super User
Super User

Here's how your code looks like after playing with it in Powerqueryformatter.com

 

  if [PT Reporting Change] = "AFTER CHANGE" then [PT2]
  else if ([activity] = "NONOPS" and [#"PT/NPT"] = "PT") then 0 
       else if ([operation] = "safety" or [operation] = "commute" or [operation] = "lunch")    then [DURATION]
            else ""

 

Your return values can be [PT2], 0, [Duration], or "" .  That's not really cool.  You want to decide on a column type and then adjust the return values accordingly.

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.