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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
perishkabb
New Member

If statement based on another column

Hello,

I'm new to Power BI and I have no idea what I'm doing 🙂

I have a column with program code (QI05, QI10, QI26, various, etc.) and a column with organizational code (R091, R092, R093 etc).

If program code is = QI41 and/or 41IRSA then the column for org.code must change to R091-RT.

If program code is = QZ09 and/or 40IRSA then the column for org.code must change to R091-FT.

How do I set this up?

 

Thank you!!!

2 ACCEPTED SOLUTIONS
Anonymous
Not applicable

Hi @perishkabb 

You need to add a custom column in Power Query to reflect these conditions and later delete the old column. This way you create a replacement.

Statement should be written like this:

if ([Program Code] = "QI41" or [Program Code]="41IRSA") then "R091-RT"
else if ([Program Code] = "QZ09" or [Program Code]="40IRSA") then "R091-FT"
else [Org Code]

 

Raymundo2910_0-1622835575841.pngRaymundo2910_1-1622835610042.pngRaymundo2910_2-1622835635687.png

I have recreated your case with a small sample. You can find the file in this link

Hope it helps 🙂 

 

View solution in original post

v-luwang-msft
Community Support
Community Support

Hi @perishkabb ,

You could use the following dax to create a new column:

org.codenew = IF('Table'[org.code]="QI41"||'Table'[org.code]="41IRSA","R091-RT",IF('Table'[org.code]="QZ09"||'Table'[org.code]="40IRSA","R091-FT",'Table'[pro.code]))

final you will get :

v-luwang-msft_0-1623055588264.png

 

Wish it is helpful for you!

 

Best Regards

Lucien

View solution in original post

3 REPLIES 3
perishkabb
New Member

Thank you both so much!!

v-luwang-msft
Community Support
Community Support

Hi @perishkabb ,

You could use the following dax to create a new column:

org.codenew = IF('Table'[org.code]="QI41"||'Table'[org.code]="41IRSA","R091-RT",IF('Table'[org.code]="QZ09"||'Table'[org.code]="40IRSA","R091-FT",'Table'[pro.code]))

final you will get :

v-luwang-msft_0-1623055588264.png

 

Wish it is helpful for you!

 

Best Regards

Lucien

Anonymous
Not applicable

Hi @perishkabb 

You need to add a custom column in Power Query to reflect these conditions and later delete the old column. This way you create a replacement.

Statement should be written like this:

if ([Program Code] = "QI41" or [Program Code]="41IRSA") then "R091-RT"
else if ([Program Code] = "QZ09" or [Program Code]="40IRSA") then "R091-FT"
else [Org Code]

 

Raymundo2910_0-1622835575841.pngRaymundo2910_1-1622835610042.pngRaymundo2910_2-1622835635687.png

I have recreated your case with a small sample. You can find the file in this link

Hope it helps 🙂 

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.