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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
rblaze1001
New Member

Creating a list from min and max values (Power Query)

Hi! Any ideas on how to do this in PowerQuery? Thanks in advance.

 

The available table looks like this:

AssigneeReceipt No. MinReceipt No. Max
A10011100
A25003000
B11011800
C30013200

 

My objective is to create a table wherein it will list per assignee all receipt nos. assigned to him like this:

AssigneeReceipt No.
A1001
A1002
A..and so on until 1100.. then do the same from 2500 to 3000
B1101
B1102.. and so on until 1800
C3001
C3002.. and so on until 3200

 

3 ACCEPTED SOLUTIONS
rohit_singh
Solution Sage
Solution Sage

Hi @rblaze1001 ,

Please try this. Copy and paste the below code in a blank query  :

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUTI0MDAEUUBaKVYHImZkCuToKBkbQMWcIArA6iygYs4QBSAxYyOQWCwA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Assignee = _t, #"Receipt No. Min" = _t, #"Receipt No. Max" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Assignee", type text}, {"Receipt No. Min", Int64.Type}, {"Receipt No. Max", Int64.Type}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each {[Receipt No. Min]..[Receipt No. Max]}),
    #"Expanded Custom" = Table.ExpandListColumn(#"Added Custom", "Custom"),
    #"Removed Columns" = Table.RemoveColumns(#"Expanded Custom",{"Receipt No. Min", "Receipt No. Max"}),
    #"Renamed Columns" = Table.RenameColumns(#"Removed Columns",{{"Custom", "Receipt No."}})
in
    #"Renamed Columns"

 

Kind regards,

Rohit


Please mark this answer as the solution if it resolves your issue.
Appreciate your kudos!




View solution in original post

hi @rohit_singh can you send the .pbix or .xlsx file you used for this? I tried to copy your solution in a blank query but it's not working. Thanks

View solution in original post

v-yalanwu-msft
Community Support
Community Support

Hi, @rblaze1001 ;

 

The code rohit_singh provided can be copied here

See the working here - Open a blank query - Home - Advanced Editor - Remove everything from there and paste the below code to test.

vyalanwumsft_0-1661850829789.pngvyalanwumsft_1-1661850971300.png

The final show:

vyalanwumsft_2-1661850993983.png


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

View solution in original post

9 REPLIES 9
Jimyf
Regular Visitor

Hello @rblaze1001

 

You can do it yourself in 3 easy steps:

 

Step 1: Add Column -> Custom Column

Jimyf_0-1662674283055.png

 

Step 2: Specify Min and Max columns

Jimyf_1-1662674323358.png

 

Step 3: Expand the New column to New Rows

Jimyf_2-1662674392925.png

 

You should get something like this:

Jimyf_3-1662674417068.png

 

You are then free to Remove the Min and Max columns if needed.

 

Best regards,

v-yalanwu-msft
Community Support
Community Support

Hi, @rblaze1001 ;

 

The code rohit_singh provided can be copied here

See the working here - Open a blank query - Home - Advanced Editor - Remove everything from there and paste the below code to test.

vyalanwumsft_0-1661850829789.pngvyalanwumsft_1-1661850971300.png

The final show:

vyalanwumsft_2-1661850993983.png


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

thanks a lot!

wdx223_Daniel
Super User
Super User

NewStep=#table({"Assignee","Receipt No."},List.TransformMany(Table.ToRows(PreviousStepName),each {_{1}.._{2}},(x,y)=>{x{0},y}))

rohit_singh
Solution Sage
Solution Sage

Hi @rblaze1001 ,

Please try this. Copy and paste the below code in a blank query  :

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUTI0MDAEUUBaKVYHImZkCuToKBkbQMWcIArA6iygYs4QBSAxYyOQWCwA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Assignee = _t, #"Receipt No. Min" = _t, #"Receipt No. Max" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Assignee", type text}, {"Receipt No. Min", Int64.Type}, {"Receipt No. Max", Int64.Type}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each {[Receipt No. Min]..[Receipt No. Max]}),
    #"Expanded Custom" = Table.ExpandListColumn(#"Added Custom", "Custom"),
    #"Removed Columns" = Table.RemoveColumns(#"Expanded Custom",{"Receipt No. Min", "Receipt No. Max"}),
    #"Renamed Columns" = Table.RenameColumns(#"Removed Columns",{{"Custom", "Receipt No."}})
in
    #"Renamed Columns"

 

Kind regards,

Rohit


Please mark this answer as the solution if it resolves your issue.
Appreciate your kudos!




thanks a lot!

hi @rohit_singh can you send the .pbix or .xlsx file you used for this? I tried to copy your solution in a blank query but it's not working. Thanks

unhinged
Frequent Visitor

let
   Source = Excel.CurrentWorkbook(){0}[Content],
   AllNumbersInRange = Table.AddColumn(Source, "Receipt No.", (x)=> List.Numbers(x[Receipt No. Min], x[Receipt    No. Max] - x[Receipt No. Min] + 1, 1 ) ),
   Expand = Table.ExpandListColumn(AllNumbersInRange, "Receipt No."),
   SelectCol = Table.SelectColumns(Expand,{"Assignee", "Receipt No."})
in
   SelectCol

How do you pin an Excel file in here? Can't seem to find a button for that.

hi @unhinged , I'm also not familiar how to pin a file here in the reply. But I've seen some who were able to do it. Would appreciate if you can share the file you used. Thanks.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors