구문
Table.ReplaceValue(
table as table,
oldValue as any,
newValue as any,
replacer as function,
columnsToSearch as list
) as table
소개
값을 테이블의 지정된 열에 있는 새 값으로 바꿉니다.
-
table: 검색할 테이블입니다. -
oldValue: 바꿀 값입니다. -
newValue: 대체 값입니다. -
replacer: 사용할 교체기 함수입니다. 함수는 원래 텍스트를 새 텍스트로 바꾸거나, Replacer.ReplaceText 원래 값을 새 값으로 바꾸거나, 사용자 지정 바꾸기를 사용할 수 Replacer.ReplaceValue 있습니다. -
columnsToSearch: 바꿀 값을 검색할 테이블의 특정 열 또는 열이 들어 있는 목록입니다.
예 1
B열에서 텍스트 "goodbye"를 "world"로 바꾸고 전체 값이 일치하는 경우에만 바꾸십시오.
사용법
Table.ReplaceValue(
Table.FromRecords({
[A = 1, B = "hello"],
[A = 2, B = "goodbye"],
[A = 3, B = "goodbyes"]
}),
"goodbye",
"world",
Replacer.ReplaceValue,
{"B"}
)
출력
Table.FromRecords({
[A = 1, B = "hello"],
[A = 2, B = "world"],
[A = 3, B = "goodbyes"]
})
예제 2
B열에서 텍스트 "ur"을 "or"로 바꾸고 값의 모든 부분과 일치하는 경우를 찾습니다.
사용법
Table.ReplaceValue(
Table.FromRecords({
[A = 1, B = "hello"],
[A = 2, B = "wurld"]
}),
"ur",
"or",
Replacer.ReplaceText,
{"B"}
)
출력
Table.FromRecords({
[A = 1, B = "hello"],
[A = 2, B = "world"]
})
예제 3
미국 직원의 이름을 익명화합니다.
사용법
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"}
)
출력
Table.FromRecords({
[Name = "*****", Country = "US"],
[Name = "Bob", Country = "CA"]
})
예시 4
미국 직원의 모든 컬럼을 익명 처리합니다.
사용법
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"}
)
출력
Table.FromRecords({
[Name = "?????", Country = "??"],
[Name = "Bob", Country = "CA"]
})