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

IF and IF ELSE in power query

Hi,

I need a custom column .

I have 2 different status from 2 diferent column.

Active_Status and Inactive_Status.

I need to create a custom column.

When Active_Status = "Active" and Inactive_Status = "Unavaliable" or Inactive_Status ="","Active" ,  Inactive_status = "Unavaliable" and Active_Status= "Active" or Active_Status ="", "Unavaliable".

Please help me.

image.png

 

1 ACCEPTED SOLUTION
v-lionel-msft
Community Support
Community Support

Hi @Anonymous ,

 

Please refer to the code(Edit the code in "Advanced Editor".).

v-lionel-msft_0-1613632391274.png

#"Added Conditional Column" = 
    Table.AddColumn(
        #"Changed Type", 
        "Custom", 
        each if [Active_status] = "Active"  and ([Inactive_Status] = "Unavaliable" or [Inactive_Status] = null)  then "Active" 
        else if ([Active_status] = "Active" or [Active_status] = null) and [Inactive_Status] = "Unavaliable" then "Unavaliable"
        else null
    )

 

Best regards,
Lionel Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
v-lionel-msft
Community Support
Community Support

Hi @Anonymous ,

 

Please refer to the code(Edit the code in "Advanced Editor".).

v-lionel-msft_0-1613632391274.png

#"Added Conditional Column" = 
    Table.AddColumn(
        #"Changed Type", 
        "Custom", 
        each if [Active_status] = "Active"  and ([Inactive_Status] = "Unavaliable" or [Inactive_Status] = null)  then "Active" 
        else if ([Active_status] = "Active" or [Active_status] = null) and [Inactive_Status] = "Unavaliable" then "Unavaliable"
        else null
    )

 

Best regards,
Lionel Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@Anonymous , Try in power query

 

if [Active_Status] = "Available" then [Active_Status] else if [Inactive_Status] ="Unavailable" then Inactive_Status else null

 

or

 

if [Active_Status] = "Available" then [Active_Status] else if [Inactive_Status] ="Unavailable" then Inactive_Status else ""

 

or

 

if [Active_Status] = "Available" then [Active_Status] else if [Inactive_Status] ="Unavailable" then Inactive_Status

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

@amitchandak 

image.png

Here is the error .

@Anonymous or where alternate ways to create columns. Use only one. example

 

if [Active_Status] = "Available" then [Active_Status] else if [Inactive_Status] ="Unavailable" then Inactive_Status else null

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

@amitchandak 

No all the 3 are not working.

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.