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
wcoetsee
New Member

Conditional replace value - No syntax error

Hi all,

I am trying to replace the value in [OriginalPathkey.4] with the number 805 if the value in [AssetType] is equal to CASHADJ but it is not working. I have tried changing the Replacer.ReplaceValue with Replacer.ReplaceText but with no success.

I have noticed that the data type of [OriginalPathkey.4] changes when applying this step, where the data type was whole number in the previous step. Thank you for your assistance.

wcoetsee_0-1646157705883.png

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

It would be easier to make a custom column like:

 

Table.AddColumn(#"Changed Type1", "NewValue" each if [AssetType] = "CASHADJ" then 805 else [OriginalPathKey.4], Int64.Type)

 

--Nate

View solution in original post

3 REPLIES 3
ronrsnfld
Super User
Super User

 

Here's one way to transform a column based on another column: (obviously using a made-up table)

 

Original

ronrsnfld_0-1646162340716.png

 

let
    Source = Excel.CurrentWorkbook(){[Name="Table12"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"OriginalPathkey.4", Int64.Type}, {"AssetType", type text}}),
    xformPathKey= Table.FromRecords(
            Table.TransformRows(#"Changed Type", (r) => 
                Record.TransformFields(r,{"OriginalPathkey.4", each if r[AssetType]="CASHADJ" then 805 else _})))
in
    xformPathKey

Result

ronrsnfld_1-1646162386086.png

 

 

 

 

PijushRoy
Community Champion
Community Champion

Hi @wcoetsee 

If problem is not solved, please share some sample data 




Did I answer your question? Mark my post as a solution!
Appreciate your Like/Kudos

Proud to be a Super User!





Anonymous
Not applicable

It would be easier to make a custom column like:

 

Table.AddColumn(#"Changed Type1", "NewValue" each if [AssetType] = "CASHADJ" then 805 else [OriginalPathKey.4], Int64.Type)

 

--Nate

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.