Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
Hello,
I am looking over a personal budget. I want to update the column Category to "Alcohol" based on a keyword in the description column (case insensitive). So...if the description contains "wine" or "liquor" change the category to "Alcohol"
I know creating a conditional column is an option but wanted to practice M-queries in power query.
Amount | Transaction Date | Description | Category | Category (#Update) |
$20.00 | 01/01/2023 | Total Wine and More | Merchandise | Alcohol |
$10.00 | 02/01/2023 | TOTAL WINE AND MORE | Merchandise | Alcohol |
$35.00 | 03/01/2023 | HOMESENSE #02567 | Merchandise | Merchandise |
$15.00 | 05/01/2023 | ABC Liquor Store | Merchandise | Alcohol |
Both columns are Text columns, if important.
The following is not working as intended. It appears what I wrote below requires the description to be an exact match for the entire cell. I want it to search each record in the category column for a single word, regardless of the case.
= Table.ReplaceValue(
#"Replaced Value1",
each [Category],
each if
Text.Contains([Description], "liquor", Comparer.OrdinalIgnoreCase) and
Text.Contains([Description], "wine", Comparer.OrdinalIgnoreCase)
then "Groceries"
else [Category],
Replacer.ReplaceText,
{"Category"})
Thanks for your help!!!
Solved! Go to Solution.
= Table.ReplaceValue(Source, each [Category], each if List.Contains({"wine","liquor"},[Description],(x,y)=>Text.Contains(y,x,Comparer.OrdinalIgnoreCase)) then "Alcohol" else [Category], Replacer.ReplaceText, {"Category"})
Expertise = List.Accumulate( {Days as from Today}, {Skills and Knowledge}, (Current, Everyday) => Current & Day.LeanAndPractise(Everyday) ) |
= Table.ReplaceValue(Source, each [Category], each if List.Contains({"wine","liquor"},[Description],(x,y)=>Text.Contains(y,x,Comparer.OrdinalIgnoreCase)) then "Alcohol" else [Category], Replacer.ReplaceText, {"Category"})
Expertise = List.Accumulate( {Days as from Today}, {Skills and Knowledge}, (Current, Everyday) => Current & Day.LeanAndPractise(Everyday) ) |
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
144 | |
85 | |
65 | |
51 | |
45 |
User | Count |
---|---|
217 | |
88 | |
81 | |
65 | |
56 |