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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Syndicate_Admin
Administrator
Administrator

Condition a column

Hello

I would like to generate a condition in which if the "Value 2" column detects that it has "null" then it takes the data from column 1.

Value 1Value 2
15
8null
2null
103

It should end like this.

Value 1Value 2
15
88
22
103

Thank you.

5 REPLIES 5
m_dekorte
Resident Rockstar
Resident Rockstar

Or simply apply a Replace Values step to the column "Value 2".

Table.ReplaceValue(PrevStepName,null,each [Value 1],Replacer.ReplaceValue,{"Value 2"})

I hope this is helpful

Edward93_0-1708855898996.png

I don't recognize this logic:

PrevStepName

That PrevStepName reference needs to be replaced with the previous step name from the Applied Steps. If you are unfamiliar or unable to pass it succesfully - try this approach:

1. In the Applied Steps pane, select the step where you want to insert this code (typically, that's the last step you see there)

2. Press the fx in front of the formula bar  - this will insert a manual step for you - AND return the previous step name.

3. Copy this step identifier from the formula bar and insert it in the place of the PrevStepName within the provided code.

4. Now you can copy and paste this updated expression back into the formula bar

 

I hope this is helpful

 

Vijay_A_Verma
Most Valuable Professional
Most Valuable Professional

Insert this step in Power Query where #"Changed Type" should be replaced with your previous step

Table.FromRecords(List.Transform(Table.ToRecords(#"Changed Type"), (x)=> Record.TransformFields(x, {"Value 2", each if x[Value 2]=null then x[Value 1] else x[Value 2]})))

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.