Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
Hi everyone,
I was trying to add another step to the result variable from this code here but kept running into the error: "The name 'result' wasn't recognized." I'd like to know how to properly correct the way I initialized the result variable if possible:
let
Source = let
CountryCleanup = (InputTable as table, ColumnName as text, optional StartRow as number) =>
let
ActualRow = if (StartRow = null) then 0 else StartRow,
result =
let
CSCountryCleanup = Table.ReplaceValue(InputTable, CSCountry{ActualRow}[CS], CSCountry{ActualRow}[Country], Replacer.ReplaceValue, {ColumnName}),
QTCountryCleanup = Table.ReplaceValue(CSCountryCleanup, QTCountry{ActualRow}[QT], QTCountry{ActualRow}[Country], Replacer.ReplaceValue, {ColumnName})
in result,
NextRow = ActualRow + 1,
OutputTable = if NextRow > (Table.RowCount(CSCountry) - 1)
then result
else @CountryCleanup(result, ColumnName, NextRow)
in OutputTable
in CountryCleanup
in
Source
The code basically tries to compare the InputTable's Country column with the CS[Country] and QT[Country] tables/columns to standardize the country names (eg: Czech Republic → Czechia, etc.). Since our dataset came from 2 different sources before merge, I am running two instances of this function (one to compare with the CS table and another to compare with the QT table) so I figured it would be better if I combined the replacements in one function.
Solved! Go to Solution.
try to change this parte of you code from:
result =
let
CSCountryCleanup = Table.ReplaceValue(InputTable, CSCountry{ActualRow}[CS], CSCountry{ActualRow}[Country], Replacer.ReplaceValue, {ColumnName}),
QTCountryCleanup = Table.ReplaceValue(CSCountryCleanup, QTCountry{ActualRow}[QT], QTCountry{ActualRow}[Country], Replacer.ReplaceValue, {ColumnName})
in result,
to:
result =
let
CSCountryCleanup = Table.ReplaceValue(InputTable, CSCountry{ActualRow}[CS], CSCountry{ActualRow}[Country], Replacer.ReplaceValue, {ColumnName}),
QTCountryCleanup = Table.ReplaceValue(CSCountryCleanup, QTCountry{ActualRow}[QT], QTCountry{ActualRow}[Country], Replacer.ReplaceValue, {ColumnName})
in QTCountryCleanup,
try to change this parte of you code from:
result =
let
CSCountryCleanup = Table.ReplaceValue(InputTable, CSCountry{ActualRow}[CS], CSCountry{ActualRow}[Country], Replacer.ReplaceValue, {ColumnName}),
QTCountryCleanup = Table.ReplaceValue(CSCountryCleanup, QTCountry{ActualRow}[QT], QTCountry{ActualRow}[Country], Replacer.ReplaceValue, {ColumnName})
in result,
to:
result =
let
CSCountryCleanup = Table.ReplaceValue(InputTable, CSCountry{ActualRow}[CS], CSCountry{ActualRow}[Country], Replacer.ReplaceValue, {ColumnName}),
QTCountryCleanup = Table.ReplaceValue(CSCountryCleanup, QTCountry{ActualRow}[QT], QTCountry{ActualRow}[Country], Replacer.ReplaceValue, {ColumnName})
in QTCountryCleanup,
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.