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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
jwi1
Post Patron
Post Patron

extracting numbers from a serie

Dear all,

 

I am looking for a solution for the following.

Below are a few container number series:

 

BMOU977351977360
BMOU977551977559
BMOU983321983321
BMOU983322983322
BMOU985193985210

 

I am looking for a formula which gives me the unique numbers in each range.

The list should then look as follows:

 

BMOU977351
BMOU977352
BMOU977353
BMOU977354
BMOU977355
BMOU977356
BMOU977357
BMOU977358
BMOU977359
BMOU977360
BMOU977551
BMOU977552
BMOU977553
BMOU977554
BMOU977555
BMOU977556
BMOU977557
BMOU977558
BMOU977559
BMOU983321
BMOU983322
BMOU985193
BMOU985194
BMOU985195
BMOU985196
BMOU985197
BMOU985198
BMOU985199
BMOU985200
BMOU985201
BMOU985202
BMOU985203
BMOU985204
BMOU985205
BMOU985206
BMOU985207
BMOU985208
BMOU985209
BMOU985210

 

Thanks upfront for your help!

regards,

John

3 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@jwi1 , If you have three columns

create a new column in power query

COl = List.Numbers([Column2],[Column3] -[Column2],1)

 

Then expand the list into rows

View solution in original post

mahoneypat
Employee
Employee

Here's one way to do it in the query editor.  To see how it works, just create a blank query, open the Advanced Editor and replace the text there with the M code below.

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcvL1D1XSUbI0Nzc2NYQyzAyUYnWQpUxhUqamlihSFsbGRoYIBrqUEYKBImVqaGkMYRgZAu2KBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t, Column3 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}, {"Column2", Int64.Type}, {"Column3", Int64.Type}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each {[Column2] .. [Column3]}),
    #"Removed Other Columns" = Table.SelectColumns(#"Added Custom",{"Column1", "Custom"}),
    #"Expanded Custom" = Table.ExpandListColumn(#"Removed Other Columns", "Custom"),
    #"Changed Type1" = Table.TransformColumnTypes(#"Expanded Custom",{{"Custom", Int64.Type}})
in
    #"Changed Type1"

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

onurbmiguel_
Super User
Super User

Hello 

Is my sugestion in Power Query: 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcvL1D7U0Nzc2NQSRZgZKsTpwQVOwoKmpJULQwtjYyBBCogoaQUgkQaBmYyBpZAg0MxYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Serial Number" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Serial Number", type text}}),
    #"Inserted First Characters" = Table.AddColumn(#"Changed Type", "First Characters", each Text.Start([Serial Number], 4), type text),
    #"Renamed Columns" = Table.RenameColumns(#"Inserted First Characters",{{"First Characters", "Prefix"}}),
    #"Inserted Text Range" = Table.AddColumn(#"Renamed Columns", "Text Range", each Text.Middle([Serial Number], 4, 6), type text),
    #"Inserted Last Characters" = Table.AddColumn(#"Inserted Text Range", "Last Characters", each Text.End([Serial Number], 6), type text),
    #"Renamed Columns1" = Table.RenameColumns(#"Inserted Last Characters",{{"Text Range", "Start"}, {"Last Characters", "End"}}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Renamed Columns1",{{"Start", Int64.Type}, {"End", Int64.Type}}),
    #"Inserted Subtraction" = Table.AddColumn(#"Changed Type1", "number rows", each [End] - [Start], Int64.Type),
    #"Added Custom" = Table.AddColumn(#"Inserted Subtraction", "individual number", each List.Numbers([Start],[number rows]+1)),
    #"Expanded Custom" = Table.ExpandListColumn(#"Added Custom", "individual number"),
    #"Added Custom1" = Table.AddColumn(#"Expanded Custom", "Custom.1", each [Prefix] & Text.From([individual number])),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom1",{"Prefix", "Start", "End", "number rows", "individual number"}),
    #"Renamed Columns2" = Table.RenameColumns(#"Removed Columns",{{"Custom.1", "Individual Number"}})
in
    #"Renamed Columns2"

image: 

onurbmiguel__0-1633088666880.png

PBIX:

https://1drv.ms/u/s!AkcWVrMFkXs1hvoY1WMhzBF2qcWemw?e=uPurjn

 

Any question ask. 

 

Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Best Regards
BC

 


Best regards


Bruno Costa | Super User


 


Did I help you to answer your question? Accepted my post as a solution! Appreciate your Kudos!! 


Take a look at the blog: PBI Portugal 


 


View solution in original post

4 REPLIES 4
onurbmiguel_
Super User
Super User

Hello 

Is my sugestion in Power Query: 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcvL1D7U0Nzc2NQSRZgZKsTpwQVOwoKmpJULQwtjYyBBCogoaQUgkQaBmYyBpZAg0MxYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Serial Number" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Serial Number", type text}}),
    #"Inserted First Characters" = Table.AddColumn(#"Changed Type", "First Characters", each Text.Start([Serial Number], 4), type text),
    #"Renamed Columns" = Table.RenameColumns(#"Inserted First Characters",{{"First Characters", "Prefix"}}),
    #"Inserted Text Range" = Table.AddColumn(#"Renamed Columns", "Text Range", each Text.Middle([Serial Number], 4, 6), type text),
    #"Inserted Last Characters" = Table.AddColumn(#"Inserted Text Range", "Last Characters", each Text.End([Serial Number], 6), type text),
    #"Renamed Columns1" = Table.RenameColumns(#"Inserted Last Characters",{{"Text Range", "Start"}, {"Last Characters", "End"}}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Renamed Columns1",{{"Start", Int64.Type}, {"End", Int64.Type}}),
    #"Inserted Subtraction" = Table.AddColumn(#"Changed Type1", "number rows", each [End] - [Start], Int64.Type),
    #"Added Custom" = Table.AddColumn(#"Inserted Subtraction", "individual number", each List.Numbers([Start],[number rows]+1)),
    #"Expanded Custom" = Table.ExpandListColumn(#"Added Custom", "individual number"),
    #"Added Custom1" = Table.AddColumn(#"Expanded Custom", "Custom.1", each [Prefix] & Text.From([individual number])),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom1",{"Prefix", "Start", "End", "number rows", "individual number"}),
    #"Renamed Columns2" = Table.RenameColumns(#"Removed Columns",{{"Custom.1", "Individual Number"}})
in
    #"Renamed Columns2"

image: 

onurbmiguel__0-1633088666880.png

PBIX:

https://1drv.ms/u/s!AkcWVrMFkXs1hvoY1WMhzBF2qcWemw?e=uPurjn

 

Any question ask. 

 

Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Best Regards
BC

 


Best regards


Bruno Costa | Super User


 


Did I help you to answer your question? Accepted my post as a solution! Appreciate your Kudos!! 


Take a look at the blog: PBI Portugal 


 


Hi @onurbmiguel_ ,

Problem solved, thanks!

John

mahoneypat
Employee
Employee

Here's one way to do it in the query editor.  To see how it works, just create a blank query, open the Advanced Editor and replace the text there with the M code below.

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcvL1D1XSUbI0Nzc2NYQyzAyUYnWQpUxhUqamlihSFsbGRoYIBrqUEYKBImVqaGkMYRgZAu2KBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t, Column3 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}, {"Column2", Int64.Type}, {"Column3", Int64.Type}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each {[Column2] .. [Column3]}),
    #"Removed Other Columns" = Table.SelectColumns(#"Added Custom",{"Column1", "Custom"}),
    #"Expanded Custom" = Table.ExpandListColumn(#"Removed Other Columns", "Custom"),
    #"Changed Type1" = Table.TransformColumnTypes(#"Expanded Custom",{{"Custom", Int64.Type}})
in
    #"Changed Type1"

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


amitchandak
Super User
Super User

@jwi1 , If you have three columns

create a new column in power query

COl = List.Numbers([Column2],[Column3] -[Column2],1)

 

Then expand the list into rows

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.