Forum Discussion
Correct Use of Text.Contains in Combination with List.Contains??
- 1 year ago
Hi thomasreick pls try this custom column
= if List.AnyTrue(List.Transform({"Gloves", "Vest", "Shorts"},
(x) => Text.Contains([item], x, Comparer.OrdinalIgnoreCase)))
then "Clothes"
else "Other" - 1 year ago
That's a well-known "feature" aka bug. The column statistics are cached and remember prior errors. Switch them off and on again to reset.
- 1 year ago
Hi thomasreick please check this, in the power query, on the advanced editor
let
CategoryMappings = [
Clothes = {"Cap", "Sleeve", "Gloves", "Vest", "Shorts", "Socks"},
Bikes = {"Mountain-", "Road-", "Race-", "Touring-"},
Accessories = {"Cage", "Dissolver", "Stand", "Rack", "Helmet", "Bottle", "Fender"},
SpareParts = {"Tire", "Patches"},
Nutrition = {}
],
GetCategory = (item as text) as text =>
let
Category = List.First(
List.Select(
Record.FieldNames(CategoryMappings),
each List.AnyTrue(
List.Transform(Record.Field(CategoryMappings, _),
(x) => Text.Contains(item, x, Comparer.OrdinalIgnoreCase))
)
)
)
in
if Category = null then "Nutrition" else Category,
AddedProductCategories_techies = Table.AddColumn(#"Changed Type1", "techies", each GetCategory([Item]), type text)in
AddedProductCategories_techies
Hi ronrsnfld,
thx for your Input. but the result ahs 100% Error although no rows are shown with 'Error' inside.
After Renaming the column Quality Column-Statistic went to green without Error. Will check the other approaches accordingly...
That's a well-known "feature" aka bug. The column statistics are cached and remember prior errors. Switch them off and on again to reset.