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.
Hi everyone,
I have the following situation:
1-) I have a table called 'Expense Category' as shown below:
2-) I have a second table with credit card statement called 'CreditCard':
What I need to achieve:
- I want Power BI to compare the column [Expense Detail] to the column [Detail] in the first table. If the 'Expese Detail' description contains any of the words in the column 'Detail', power BI will bring the correspondent 'Category' value to my CreditCard table in a new column 'Category' just beside the 'Account' column
Something like this:
any thoughts ?
thanks!
Julio
Solved! Go to Solution.
Hi @Julio-YYC ,
Please try like:
= Table.AddColumn(#"Changed Type", "Category", each Table.SelectRows(#"Expense Category",(x)=>Text.Contains([Expense Detail],x[Detail],Comparer.OrdinalIgnoreCase))[Category]{0})
and then repalce error.
Best Regards,
Gao
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data
Hi Bifinity_75, I tested your solution, and it worked great also. I've got two distinct solutions for the same issue. appreciated. thanks.
Hi @Julio-YYC , try this calculate column:
Category =
maxx(filter('Expense Category' ,
search('Expense Category'[Detail], CreditCard[Expense Detail],,0)>0),'Expense Category'[Detail]
)
Best regards
Hi Bifinity_75, I tested your solution, and it worked great also. I've got two distinct solutions for the same issue. appreciated. thanks.
Hi @Julio-YYC ,
Please try like:
= Table.AddColumn(#"Changed Type", "Category", each Table.SelectRows(#"Expense Category",(x)=>Text.Contains([Expense Detail],x[Detail],Comparer.OrdinalIgnoreCase))[Category]{0})
and then repalce error.
Best Regards,
Gao
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data
it worked nice Gao, thanks! one more question, in a case where there is no match between 'Expense Detail' and the 'Detail' column, how can I get 'Others' as a result for the Category instead of the error message shown below?
thanks!
Julio
Good point daXtreme...! I'm gonna follow your suggestion above...many thanks!
I wouldn't do that. It'll be painfully slow on a bigger data set. Instead, I'd use Power Query to break down the phrases into individual words stored in one column and then use such a table to match against these words. This is acually how it should be handled in a professional model.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
100 | |
66 | |
48 | |
39 | |
32 |
User | Count |
---|---|
166 | |
117 | |
61 | |
58 | |
42 |