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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

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
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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