Table.ReplaceValue
Syntax
Table.ReplaceValue(table as table, oldValue as any, newValue as any, replacer as function, columnsToSearch as list) as table
Névjegy
A oldValue
newValue
a megadott oszlopokra cseréli a table
elemet.
1. példa
Cserélje le a "viszlát" szöveget a "world" (világ) szövegre a B oszlopban, amely csak a teljes értéknek felel meg.
Használat
Table.ReplaceValue(
Table.FromRecords({
[A = 1, B = "hello"],
[A = 2, B = "goodbye"],
[A = 3, B = "goodbyes"]
}),
"goodbye",
"world",
Replacer.ReplaceValue,
{"B"}
)
Hozam
Table.FromRecords({
[A = 1, B = "hello"],
[A = 2, B = "world"],
[A = 3, B = "goodbyes"]
})
2. példa
Cserélje le az "ön" szöveget a B oszlopban lévő "vagy" szövegre, amely megfelel az érték bármely részének.
Használat
Table.ReplaceValue(
Table.FromRecords({
[A = 1, B = "hello"],
[A = 2, B = "wurld"]
}),
"ur",
"or",
Replacer.ReplaceText,
{"B"}
)
Hozam
Table.FromRecords({
[A = 1, B = "hello"],
[A = 2, B = "world"]
})
3. példa
Anonimizálja az egyesült államokbeli alkalmazottak nevét.
Használat
Table.ReplaceValue(
Table.FromRecords({
[Name = "Cindy", Country = "US"],
[Name = "Bob", Country = "CA"]
}),
each if [Country] = "US" then [Name] else false,
each Text.Repeat("*", Text.Length([Name])),
Replacer.ReplaceValue,
{"Name"}
)
Hozam
Table.FromRecords({
[Name = "*****", Country = "US"],
[Name = "Bob", Country = "CA"]
})
4. példa
Az usa-beli alkalmazottak összes oszlopának anonimizálása.
Használat
Table.ReplaceValue(
Table.FromRecords({
[Name = "Cindy", Country = "US"],
[Name = "Bob", Country = "CA"]
}),
each [Country] = "US",
"?",
(currentValue, isUS, replacementValue) =>
if isUS then
Text.Repeat(replacementValue, Text.Length(currentValue))
else
currentValue,
{"Name", "Country"}
)
Hozam
Table.FromRecords({
[Name = "?????", Country = "??"],
[Name = "Bob", Country = "CA"]
})