DAX Search and Lookup (Something like a VLookup)

jives00

New Member
Joined
Feb 27, 2015
Messages
7
I have a long list of transaction data that contains many different vendor names. Some of the vendors have a unique name for each and every transaction (e.g. FedEx appends a portion of the tracking # to each vendor name for some reason, Jewel includes the store number, Dell uses DMI with a number sometimes, and Dell other times, etc. etc.).

I want to user PowerPivot to "normalize" some of these names so that it becomes easier to pull total spend and other data (e.g. just show me how much was spent with FedEx). The transaction data is source data, so I'm stuck with it as is.

What I want to do is create another table that says what I'm searching for in each vendor name and what it's normalized name should be. Anytime the phrase fedex appears in the vendor name (start, finish, in the middle, could be anywhere in that field) column in the source data, PowerPivot should know that's actually FedEx. I have no idea what this list of vendors to normalize is and it will probably change over time so it needs to be flexible and not have to update the formula each time.

I have no idea what the formula is then to link these together. I'm picturing a calculated field in the transactions table that:

1) Looks at the Transactions[VendorName] column
2) Searches it against the AutoName[SearchTerm] column
3) If it finds a match (they will not be exact matches) add the AutoName[NormalName] in the calculated field.

Table: Transactions
Vendor Name | Amount
FedEx 42351 | $15.24
FedEx 58563 | $12.11
Jewel #1231 | $89.12
DMI | $2003.24
Dell | $1254.52

Table: AutoName
SearchTerm | NormalName
fedex | FedEx
jewel | Jewel
dmi | Dell
dell | Dell

Table: Transactions w/ calculated column
Vendor Name | Normal Name | Amount
FedEx 42351 | FedEx | $15.24
FedEx 58563 | FedEx | $12.11
Jewel #1231 | Jewel | $89.12
DMI | Dell | $2003.24
Dell | Dell | $1254.52

Thoughts? Thanks for the help!
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Per transaction - just 1. So a line item showing we paid FedEx 1234, would only need to show FedEx in the calculated field.
 
Upvote 0
You might try Power Query to clean up this data first. Split the Vendor Name column on space and then do some replace values. Then as new variations come in just add them to your replace list
 
Upvote 0
See if this helps you?
tinylizard.com/dax-contains-function/

What you are trying to do is certainly possible.
 
Upvote 0
The Contains function might work, I just need to figure out the syntax. Thoughts? Basically if [column] contains [lookup column] put in [another lookup column]. E.g. If the Vendor Name contains FedEx (even if it has extra letters/numbers in it somewhere), then make the Normal Name FedEx. I'm not sure what exactly that formula is yet. Also, do you know if Contains can be restricted further in some way... e.g. Dell could show up as a vendor but also things like Michael O'Dell.

The Power Query splitting on space won't work, we have a good deal of vendors who have more than one word in their name.
 
Upvote 0
Ya, I was on crack w/ the contains think :)

I think I called your AutoName my "Lookup". Go find the first row that isn't blank... by evaluating each Lookup name... and using it as the first param to search -- returning blank if it doesn't match. or something like that :)

=FIRSTNONBLANK(Lookup[Lookup], search(Lookup[Lookup], Names[Full Name], 1, BLANK()))

DVUk1hS.png
 
Upvote 0
Thanks close, thanks!

(Scratch my previous comment if you saw it already)

I changed the formula slightly to be: =FIRSTNONBLANK(Lookup[Lookup], search(Lookup[Lookup], [Original Name], 2, BLANK()))

This lets me put in two columns, one for the name it's searching on (e.g. FDEX) and the other what I want (e.g. FedEX). So it works, awesome and thank you!!

However, this raises another issue - sometimes it has a false positive. For example I saw a name "Tina Crandell" got renamed to "Dell". Any thoughts on how we can build in some logic around that? Maybe something like it must be a search on full word, not as part of another word?

Thanks again!
 
Last edited:
Upvote 0
Hm, it won't let me edit the post now. Ignore the formula change. Using 2 doesn't do what I thought it did so I went back to 1.

Still have the search issue though (Crandell becomes Dell) and names that aren't in the name (e.g. FDEX needs to become FedEx). Thoughts?
 
Upvote 0
Ick. This sort of data cleaning is better suited to... almost any tool but Power Pivot :) Likely Power Query would be a least "better" (I dont think it supports regular expressions yet though) --- you could split by whitespace and do some matching maybe.

I typically script something in power shell, but I love it.
 
Upvote 0

Forum statistics

Threads
1,224,081
Messages
6,176,259
Members
452,717
Latest member
victorski

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