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
Anonymous
Not applicable

Need help converting excel statement power query

Is it possible to create a custom column with a series of if statements that produce a concatenated string? I have done this in Excel but can't recreate it in power query for a custom column.  My excel text is as follows: 

 

=IF([@[Customer Survey Status]] ="Completed", 1,(IF(Customer Survey Status="In Review",1,0))) & "," & IF([@[Partner Survey Status]]="Completed", 1,(IF([@[Partner Survey Status]]="In Review",1,0))) & "," & IF([@[Document Status]]="Completed",1,(IF([@[Document Status]]="In Review",1,0))) & "," & IF([@[Invoice Status]]="Completed",1,(IF([@[Invoice Status]]="In Review",1,0)))

 

I've tried the If statement and the text.contains methods but can't get either to work. 

 

Result desired is something like 0,1, 0,1

 

I did post a 30 minutes ago but can't see it in the forums so reposting, sorry if this is a duplicate. 

Thanks!

 

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

You can pretty much directly translate this into Power Query code.  There are no brackets for if ... then ... else  but the rest is nearly the same.

 

Something like 

 

 

=Table.AddColumn(#"Previous Step", each 
(if [Customer Survey Status] ="Completed" or [Customer Survey Status]="In Review" 
    then "1," else "0,") & 
(if [Partner Survey Status]="Completed" or [Partner Survey Status]="In Review" 
    then "1," else "0,") & 
(if [Document Status]="Completed" or [Document Status]="In Review" 
    then "1," else "0,") &
(if [Invoice Status]="Completed" or [Invoice Status]="In Review" 
    then "1" else "0")
)

 

Or if you want to use List.Contains: 

 

 

=Table.AddColumn(#"Previous Step", each
let l = {"Completed","In Review"}
in  
(if List.Contains(l,[Customer Survey Status] then "1," else "0,") & 
(if List.Contains(l,[Partner Survey Status] then "1," else "0,") & 
(if List.Contains(l,[Document Status] then "1," else "0,") &
(if List.Contains(l,[Invoice Status] then "1" else "0")
)​

View solution in original post

2 REPLIES 2
lbendlin
Super User
Super User

You can pretty much directly translate this into Power Query code.  There are no brackets for if ... then ... else  but the rest is nearly the same.

 

Something like 

 

 

=Table.AddColumn(#"Previous Step", each 
(if [Customer Survey Status] ="Completed" or [Customer Survey Status]="In Review" 
    then "1," else "0,") & 
(if [Partner Survey Status]="Completed" or [Partner Survey Status]="In Review" 
    then "1," else "0,") & 
(if [Document Status]="Completed" or [Document Status]="In Review" 
    then "1," else "0,") &
(if [Invoice Status]="Completed" or [Invoice Status]="In Review" 
    then "1" else "0")
)

 

Or if you want to use List.Contains: 

 

 

=Table.AddColumn(#"Previous Step", each
let l = {"Completed","In Review"}
in  
(if List.Contains(l,[Customer Survey Status] then "1," else "0,") & 
(if List.Contains(l,[Partner Survey Status] then "1," else "0,") & 
(if List.Contains(l,[Document Status] then "1," else "0,") &
(if List.Contains(l,[Invoice Status] then "1" else "0")
)​
Anonymous
Not applicable

Thanks so much, this really helped! 

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!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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.