Forum Discussion

recho's avatar
recho
Copper Contributor
May 14, 2020
Solved

How to create custom column based on multiple conditions in power query

I have a list of conditions that need to be checked in order to populate a new column:

 

IF [DeviceType] = "ValveSO" AND [Extension] = ".Out" Then [PointTag]

OR

IF [DeviceType] = "ValveC" AND [Extension] = ".Out_CV" Then [PointTag]

OR 

IF [DeviceType] = "ValveMO" AND [Extension] = ".Out_Open" Then [PointTag]

OR 

IF [DeviceType] = ""  Then [PointTag]

 

I have not found a way to do this..

 

Thanks in advance

  • recho 

     

    You should try it like this...

     

    if [DeviceType] = "ValveSO" and [Extension] = ".Out" then [PointTag]
    
    else
    
    if [DeviceType] = "ValveC" and [Extension] = ".Out_CV" then [PointTag]
    
    else
    
    if [DeviceType] = "ValveMO" and [Extension] = ".Out_Open" then [PointTag]
    
    else
    
    if [DeviceType] = null  then [PointTag]
    
    else
    
    null

3 Replies

  • recho 

     

    You should try it like this...

     

    if [DeviceType] = "ValveSO" and [Extension] = ".Out" then [PointTag]
    
    else
    
    if [DeviceType] = "ValveC" and [Extension] = ".Out_CV" then [PointTag]
    
    else
    
    if [DeviceType] = "ValveMO" and [Extension] = ".Out_Open" then [PointTag]
    
    else
    
    if [DeviceType] = null  then [PointTag]
    
    else
    
    null

Resources