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

Preparing for a certification exam? Ask exam experts all your questions on May 15th. Register now.

Reply
DROG1025
New Member

IF statement without adding new column

Good morning,

 

I am very new to Power Bi. I am trying to write an if statement for the below data. I have tried copying the syntax from other similar inquiries on this site, but no luck. What I am trying to do:

 

If YN NUMBER = "#N/A" then BIN NUMBER = "#N/A

But if YN NUMBER = "YNA0372094 or any other YN Number on the spreadsheet" then BIN NUMBER = "Active Not Sourced"

 

I have included the syntax for what I have been trying, but i just keep coming up with a screen that says "false"

 

DROG1025_0-1744383334620.png

DROG1025_1-1744383355231.png

 

Any help is greatly appreciated!!

1 ACCEPTED SOLUTION
SundarRaj
Resolver V
Resolver V

Hi @DROG1025 , anothe solution you could try: I have taken certain assumptions here:
1. YN Number being your first column. If that's not the case, let me know and I'll send the edited version.

SundarRaj_0-1744388735997.png

SundarRaj_2-1744388905426.png

 

SundarRaj_1-1744388755863.png

 

Here's the code:

let
Source = Excel.CurrentWorkbook(){[Name="Table3"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"YN NUMBER", type text}, {"BIN NUMBER", type text}}),
RecAsList = Table.TransformRows(#"Changed Type", each _ & [BIN NUMBER = if Text.End(Record.FieldValues(_){0},1) = "A" then "NA" else "Active Not Sourced"]),
Table = Table.FromRecords(RecAsList)
in
Table

View solution in original post

4 REPLIES 4
v-karpurapud
Community Support
Community Support

Hi @DROG1025 

We would like to confirm that the solution provided by @SundarRaj  is accurate and resolves the issue. Could you please confirm if your query has been resolved? If it has, kindly mark the helpful response and accept it as the solution. This will help other community members resolve similar issues more efficiently. If not, please provide detailed information so we can assist you better.

Thank you

SundarRaj
Resolver V
Resolver V

Hi @DROG1025 , anothe solution you could try: I have taken certain assumptions here:
1. YN Number being your first column. If that's not the case, let me know and I'll send the edited version.

SundarRaj_0-1744388735997.png

SundarRaj_2-1744388905426.png

 

SundarRaj_1-1744388755863.png

 

Here's the code:

let
Source = Excel.CurrentWorkbook(){[Name="Table3"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"YN NUMBER", type text}, {"BIN NUMBER", type text}}),
RecAsList = Table.TransformRows(#"Changed Type", each _ & [BIN NUMBER = if Text.End(Record.FieldValues(_){0},1) = "A" then "NA" else "Active Not Sourced"]),
Table = Table.FromRecords(RecAsList)
in
Table

bhanu_gautam
Super User
Super User

@DROG1025 To create an if statement in Power BI using DAX (Data Analysis Expressions), you can use the IF function. Based on your requirements, you want to check the value of YN NUMBER and assign a value to BIN NUMBER accordingly.

 

DAX
BIN NUMBER =
IF(
[YN NUMBER] = "#N/A",
"#N/A",
"Active Not Sourced"
)

 

 

If you want to modify the existing BIN NUMBER column based on the condition without adding a new column in Power Query, you can use the "Replace Values" feature with a custom formula. Here’s how you can do it:

Open your Power BI Desktop.
Go to the "Home" tab and click on "Transform Data" to open Power Query Editor.
Select the column BIN NUMBER.
Go to the "Transform" tab and click on "Replace Values".
In the "Replace Values" dialog box, click on the small arrow next to the "Replace" button and select "Replace Using Formula".
Enter the following formula in the "Replace Using Formula" dialog box:
m
if [YN NUMBER] = "#N/A" then "#N/A" else "Active Not Sourced"
Click "OK".




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






@bhanu_gautam it does not appear that I have the small arrow next to the replace button. Screenshot below

DROG1025_1-1744389085074.png

 

 

Helpful resources

Announcements
PBIApril_Carousel

Power BI Monthly Update - April 2025

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

Notebook Gallery Carousel1

NEW! Community Notebooks Gallery

Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.

April2025 Carousel

Fabric Community Update - April 2025

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

Top Solution Authors