Forum Discussion
recho
May 14, 2020Copper Contributor
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
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
Sort By
- Subodh_Tiwari_sktneerSilver Contributor
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
- rechoCopper ContributorThanks Subodh, that worked!
- Subodh_Tiwari_sktneerSilver Contributor
You're welcome! Glad it worked as desired.