Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Merge Queries by text contain

Hello everyone, I refer to this query https://community.powerbi.com/t5/Power-Query/Merge-by-Text-Contain-Any-Multiple-values-in-a-row/td-p... as I have a similar issue. (Also @Nolock , since you provided the solution)

 

I have a query containing of contacts' infomation, including the column below (snippet): 

Title
CFO
Regional Chief Financial Officer
Senior Manager
Group Chief Officer- New Business Models
Snr Manager, Finance
Head of Human Resources, Asia
Vice President, Group IT Planning & Solution Delivery
Senior Vice President Head of High Impact Team
Regional Chief Actuary
Chief Financial Officer
Chief Finance Officer
Chief Risk Officer
VP, Finance
Manager, Group Operational Risk
Tax-Manager

 

I intend to map in function categories (from another query) using the titles column.

The snippet of the second query is as below:

FunctionTitles
FinanceWealth Management
RiskUnderwrit
FinanceTreasurer
Digital/InnovationTechnology
TaxTax
StrategyStrategy
StrategyStrategic
HRStaff
RiskRisk
Head of companyPrincipal
Head of companyPresident
StrategyPlanning
Head of companyOwner
OperationsOps
OperationsOperations
OperationsOperation
OperationsOperating

 

As long as the titles in the first query contain words that is in the titles column in second query, the function category should be mapped in to the first query.

After mapping in, my first query should have a title column and also a function column showing the category of the title.

 

Thank you 🙂

 

(edited for clarity)

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Thank you very much everyone for your input!

 

I found a simple solution here https://powerpivotpro.com/2019/02/powerquerymagic-conditional-joins-using-table-selectrows/  and it worked for me perfectly.

 

Cheers!

View solution in original post

10 REPLIES 10
Anonymous
Not applicable

Thank you very much everyone for your input!

 

I found a simple solution here https://powerpivotpro.com/2019/02/powerquerymagic-conditional-joins-using-table-selectrows/  and it worked for me perfectly.

 

Cheers!

v-juanli-msft
Community Support
Community Support

Hi @Anonymous 

Is this problem sloved? 
If it is sloved, could you kindly accept it as a solution to close this case and help the other members find it more quickly?
If not, please feel free to let me know.
 
Best Regards
Maggie
Anonymous
Not applicable

It'd be great if anyone can help me regarding this! Thank you.

Remember that the table join functions support using other functions as joiner operators. You can do much (MUCH) more than just fuzzy matches. Conditional joins with complex logic over multiple fields - no problem. Imke Feldmann covered that, I can provide examples too.

Anonymous
Not applicable

Ooh I see. Is there any particular example that I can refer to?

Here's my proudest work so far:

 

    #"Added Custom" = Table.AddColumn(Index, "Match", 
        (k) => Table.SelectRows(#"Assignments",
            each ([LocID]="*" or k[LocID]=[LocID])
                and ([PSA]="*" or k[PSA]=[PSA])
                and ([ST ID]="*" or k[ST ID]=[ST ID])
                )
            ),

 

This does a semi-fuzzy match across three fields of the two tables. 

Anonymous
Not applicable

here an exemple of use of List.transformMany and a very basic Fuzzy compare function:

 

let
ruleList=Table.ToRecords(ruleTab),
tab=Table.FromRecords(List.TransformMany(dataTab[Titles], each ruleList,(x,y)=> if MyFuzzy(x,y[Titles]) then [Titles=x,Function=y[Function]] else [Titles=x,Function=null])),
    #"Rimossi duplicati" = Table.Distinct(tab, {"Titles","Function"}),
    #"Raggruppate righe" = Table.Group(#"Rimossi duplicati", {"Titles"}, {{"Func", each _[Function]}}),
    #"Valori estratti" = Table.TransformColumns(#"Raggruppate righe", {"Func", each Text.Combine(List.Transform(_, Text.From)), type text})
   in
    #"Valori estratti"

 

 

MyFuzzy:

 

let

myFuzzy=(fieldData,fieldRules)=> 

let
listRules=Text.SplitAny(Text.Lower(fieldRules)," -,"),

listData=Text.SplitAny(Text.Lower(fieldData)," -"),

fuzzyMatch=List.ContainsAny(listRules,listData)


in 
fuzzyMatch
in
myFuzzy

 

 

You may need to add more details to your post (see links below) but it seems a Fuzzy Match using a Transformation Table would work.

2020-06-16 18_17_25-.png

 

MS defines the transformation table as:

Transformation table – This option allows users to specify another query that holds a mapping table, so that some values can be auto-mapped as part of the matching logic. For example, defining a two-column table with a “From” and “To” text columns with values “Microsoft” and “MSFT” will make these two values be considered the same (similarity score of 1.00) by the matching logic.

 

How to get good help fast. Help us help you.
How to Get Your Question Answered Quickly
How to provide sample data in the Power BI Forum



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting
Anonymous
Not applicable

Hey. Apologies because this is my first time posting.

 

What other information would I need to put up here? Do you mean my whole table, or all the rows for the columns?

 

I basically have one table query that contains 1000+ contacts with their name, organisations, titles, emails and everything. It's sort of like a contacts dimension table.

 

Contacts Dimension Table:

Last NameTitle
AAACFO
BBBRegional Chief Financial Officer
CCCSenior Manager
DDDGroup Chief Officer- New Business Models
EEESnr Manager, Finance
FFFHead of Human Resources, Asia
GGGVice President, Group IT Planning & Solution Delivery
HHHSenior Vice President Head of High Impact Team
IIIRegional Chief Actuary
JJJChief Financial Officer
KKKChief Finance Officer
LLLChief Risk Officer
MMMVP, Finance
NNNManager, Group Operational Risk
OOOTax-Manager
PPPChief Strategy Officer, Strategy & Transformation

 

I have another title dimension table containing the different titles and categories that the titles belong to.

 

Category-Titles Dimension Table:

CategoryTitles
Head of companyCEO
Head of companyManaging Director
Head of companyGeneral Manager
Head of companyChairman
FinanceCFO
FinanceFinance
FinanceTreasurer
RiskRisk
RiskActuarial
OperationsOperations
StrategyStrategy
ITInformation
ITIT 
TaxTax
HRHuman Resource
HRHR 

 

Using this titles dimension table, I would like include the category in the contacts dimension table. However, the issue here is that I am unable to use an exact match for the titles. I'm thinking more of if the title of the contact contains a word of the titles in the title dimension table, the category would be mapped over.

 

So the end product for example:

Last NameTitleCategory
AAACFOFinance
EEESnr Manager, FinanceFinance

and so on.

 

Hopefully this is much clearer? Thank you. Let me know if anyone needs more information.

 

Anonymous
Not applicable

 

if I understand your need well, you should take a look at the following link

 

Replace-Values-in-Column-Conditionally-using-Rules-Table 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors