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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
antoineL
Frequent Visitor

Decoding GS1-128 packed data into separate AIs

Hi. Newbie user of PowerQuery, so please excuse me is there is an obvious answer in the documentation, which I did not fully read before asking.

 

GS1-128 is a barcode encoding where the data are strings of characters prefixed with a 2-digit application identifier (AI), strings which are then concanated.

I got readings from a barcode scanners which are packed, i.e. the example from the wikipedia page would show as

00123456780000000001
2112345 1109010117100101
11090101171001012112345

(let's ignore for a moment 4-digit AIs, or the encoding of [FNC1] since I cannot write "character" GS on the board.)

 

I would like to transform those readings into a number of columns, one for each AI.

I believe it should be possible to extract several columns in M.

But what I am not easy with is to "consume" the input and how to "slice" it.

 

In traditional programming languages, it would use an index/pointer initialised to the begining of the string, a do{}until(end-of-string) loop and a select/case based on next two characters then advance pointer. But I do not know how to translate that logic into M...

2 REPLIES 2
v-yingjl
Community Support
Community Support

Hi @antoineL ,

If all fields in the coumn have the same length and format, you can use split columns in power query directly, please refer:

  1. Split columns by number of characters 
  2. How to Split Columns in Power BI 

 

If not, I think need to group them first which have the same length and format and then use split columns by number of characters.

 

Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

AlB
Community Champion
Community Champion

Hi @antoineL 

Please show clearly the initial data and the expected result

Share it in text-tabular format so that the contents can be copied


SU18_powerbi_badge

Please accept the solution when done and consider giving a thumbs up if posts are helpful. 

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers

 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

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