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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
monojchakrab
Resolver III
Resolver III

Problem with extracting numeric characters based on a pre-specified list

Hiya good people of Power query,

 

I probably have reached out with the same problem before and even accepted some of the solutions proferred here. But I am continuing to have the problem since the strings keep on changing.

 

I have a column of texts, from which I have removed all text characters and now have a column with only numeric characters. But these strings come in various shapes and sizes. A few snippets as below :

 

monojchakrab_0-1690296985673.pngmonojchakrab_1-1690297014463.pngmonojchakrab_2-1690297048951.pngmonojchakrab_3-1690297085496.pngmonojchakrab_4-1690297109614.png

There are other types - but you probably get the drift, right?

While these strings look ominously inaccessible, what is common though is that each type contains the pack size as the numeric characters - like 100, 500, 50, 110, 80, 300, 100 etc...

I have a prepared a separate list of all those possible pack sizes (list named as Packlist) in a separate list as below :

monojchakrab_5-1690297306192.png

My challenge is to extract only those numeric characters when there is a match with the numbers contained in the Packlist else it should return 1...I have tried various routes (inlcuding chatGPT!) but none is able to solve the problem for all the character types.

Is it possible to design a generic code to achieve this? I am somehow not able to get around to using List.Accumulate and List.Generate to solve this, but probably the best solution would involve those functions.

 

Thanking you all in advance

 

best regds.,

 

1 REPLY 1
Anonymous
Not applicable

I would find each combination of delimiters between which your values reside, make a separate query that extracts the values based on each of these delimiter combinations, and then combine (append) the tables.  For example, a table like 

 

Source = Table.TransformColumns(Table1, {{"Values", each Text.BetweenDelimiters(_, "(", "||"), type text}}),

RemoveNulls = Table.SelectRows(Source, each [Values] <> "")

 

Then another table like

 

= Table.TransformColumns(Table1, {{"Values", each Text.BetweenDelimiters(_, "#|||", "#"), type text}})

the values based on each of these delimiter combinations, and then combine (append) the tables.  For example, a table like 

 

Source = Table.TransformColumns(Table1, {{"Values", each Text.BetweenDelimiters(_, "(", "||"), type text}}),

RemoveNulls = Table.SelectRows(Source, each [Values] <> "")

 

Source = Table.TransformColumns(Table1, {{"Values", each Text.BetweenDelimiters(_, ",,", ","), type text}}),

RemoveNulls = Table.SelectRows(Source, each [Values] <> "")

 

Once you are sure you've found all of the different delimiter combinations, then use the GUI Append Tables function to combine all of the tables. Not easy, but I can't think of another way to do it!

 

--Nate

 

 

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.