PowerQuery, Use partial keywords auto-match

nikio8

Board Regular
Joined
Oct 20, 2017
Messages
128
Hi all, thanks for your help in advance.
Essentially reconciling very similar description data every day.

Sometimes there are the same description which can give meaning to several columns (has tax, which company, which accounting expense code...) and very little needs to be done.

The problem is other data either has date or $ amounts, which vary. It would be great to partially search and auto-match. Perhaps unique keywords can be set up, and merge table can be used. It would be nice to set up database (table) that does say ,

AMEX $23.58 8989889 | "AMEX8989889" | => (store name, credit card, Amex, exp code)
CompanyNameX 22/7/2018 | "CompanyNameX" | ...
ContractorA | "ContractorA" | ...

The point of this would be to have table that is easy to edit. It is almost the same data every day, why use complex formulas and many "if else" ?

This is were I am thus far. If rows in Data1 have any of the conversion words, they are stored in output table.
I would like to returrn first word from Converion or null.

Data1OutputConversion
The red barnThe red barnRed
A yellow carBlue jeansBlue
Blue jeansGreen beansGreen
Green beansChicago blue
Atlanta
Chicago blue

<tbody>
</tbody>

Code:
let    Source = Excel.CurrentWorkbook(){[Name="DataTable"]}[Content],    
    LookUp = Excel.CurrentWorkbook(){[Name="ConversionTable"]}[Content],
    #"Value" = 
        //Table.SelectRows(table as table, condition as function) as table         
        Table.SelectRows(Source, (r)=>   List.AnyTrue(
                                                    List.Transform(
                                                        LookUp[Conversion],
                                                        each Text.Contains(r[Data1], _, Comparer.OrdinalIgnoreCase)
                                                        ))
                                                    
                        )
in
    #"Value"
 
List.Select takes the list named ListToSearch and filters it based on the result of the logical expression that was used as second argument (Text.Contains), if true it keeps the item if false it discards it

once ListToSearch has been filtered, Text.Combine takes this list and combines it using a comma as separator

List.Select(ListToSearch, Text.Contains) = keep only the items that are part of the current description
Text.Combine combine the filtered items by a comma
 
Upvote 0

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number

Forum statistics

Threads
1,214,926
Messages
6,122,306
Members
449,079
Latest member
juggernaut24

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top