Lookup table with comma separated values

SachinC

New Member
Joined
Sep 25, 2017
Messages
26
I have a master table with values. My master table has a TagId column with values such as TagId: 123,321,344,455 and a combination of one value, two values, four values etc... (all comma separated).
These numbers correspond to campaign names and these are in a separate table, i.e. 123 This is a test, 321 Hello, 344 This is another test etc.... There are around 40-odd lines in my lookup table with columns: Id (autonumber), ID, TagId, CampaignName
Can you tell me how I can get my Campaign names in place from TagId as I will need to report on the data in PowerBI using Access DB as my datasource?
Do I create a new Query...???
Thanks.
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Have been dabbling in Access for 30 years and only once in that time did I ever have a need to keep csv data in a table. Unless you have a good reason for doing that, you probably should properly normalize your data. Otherwise, the only way I can see getting your names out is to use code that breaks your csv values into an array but not sure what you'd do with them at that point. Possibly create records in a temp table or a staging table (along with the CampaignName field), because a query that calls a function can only accept one return value per record, and you have several values in one field. You'd use that temp/staging table in a query that joins that table to your names table on CampaignNames fields. Perhaps this could also be done by using a temporary TableDef, but while that's slicker, it's more complicated.

Having said all that, some PowerBI guru will probably whip up something for you 10 minutes after reading these posts.
 
Upvote 0
I would also say just normalize your table, then you would not have an issue.
 
Upvote 0
With this layout, in Power BI, you can use Power Query

Book6
ABCDEFGH
1Source DataOutputLOOK UP
2
3Column1Column1EquivCodeEquiv
4123,456,789,012123A123A
5234,456,891,123456B456B
6456B789C
7789C012D
8012D234E
9234E891F
10891F
11123A
Sheet2


Power Query:
let
    T1 = Excel.CurrentWorkbook(){[Name="Table3"]}[Content],
    CT = Table.TransformColumnTypes(T1,{{"Column1", type text}}),
    SCD = Table.ExpandListColumn(Table.TransformColumns(CT, {{"Column1", Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv), let itemType = (type nullable text) meta [Serialized.Text = true] in type {itemType}}}), "Column1"),
    T2=Excel.CurrentWorkbook(){[Name="Table4"]}[Content],
    CT2 = Table.TransformColumnTypes(T2,{{"Code", type text}, {"Equiv", type text}}),
    MQ = Table.NestedJoin(SCD, {"Column1"}, CT2, {"Code"}, "Table2", JoinKind.FullOuter),
    ET = Table.ExpandTableColumn(MQ, "Table2", {"Equiv"}, {"Equiv"})

in
    ET
 
Upvote 0
With this layout, in Power BI, you can use Power Query

Book6
ABCDEFGH
1Source DataOutputLOOK UP
2
3Column1Column1EquivCodeEquiv
4123,456,789,012123A123A
5234,456,891,123456B456B
6456B789C
7789C012D
8012D234E
9234E891F
10891F
11123A
Sheet2


Power Query:
let
    T1 = Excel.CurrentWorkbook(){[Name="Table3"]}[Content],
    CT = Table.TransformColumnTypes(T1,{{"Column1", type text}}),
    SCD = Table.ExpandListColumn(Table.TransformColumns(CT, {{"Column1", Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv), let itemType = (type nullable text) meta [Serialized.Text = true] in type {itemType}}}), "Column1"),
    T2=Excel.CurrentWorkbook(){[Name="Table4"]}[Content],
    CT2 = Table.TransformColumnTypes(T2,{{"Code", type text}, {"Equiv", type text}}),
    MQ = Table.NestedJoin(SCD, {"Column1"}, CT2, {"Code"}, "Table2", JoinKind.FullOuter),
    ET = Table.ExpandTableColumn(MQ, "Table2", {"Equiv"}, {"Equiv"})

in
    ET
This is fantastic. Exactly what I need. I am actually using MS Access. I have a master table (with a column called TAGId) and lookup table with TagId and Description, I need the TagId resolved to Description. Look forward to your response. Thanks.
 
Upvote 0
Bring your tables into Power Query and run the Mcode. Modify the code to reflect the table and field names of your tables and/or queries. This google lookup will help you to bring that data in


What version of Excel are you running? In O365, power query is called Get and Transform Data and found on the Data Ribbon. Suggest you update your profile to indicate your Excel/Access versions so that responses can be catered to your particular version.
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,155
Members
453,021
Latest member
Justyna P

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