Forum Discussion
IF statement without adding new column
- 1 year ago
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.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
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".
- DROG10251 year agoNew Member
bhanu_gautam it does not appear that I have the small arrow next to the replace button. Screenshot below