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
François
Helper I
Helper I

How to split a line in multiple lines based on all the integer values between two columns' values

I have lines with zipcodeFrom and zipcodeTo

 

For instance
ARMENIA     ARTIK      3001     3007
I would like to get 7 lines, one for each possible zipcode : 3001,3002,3003, etc...

how can I do that using PowerQuery Editor ? I was thinking about adding a costum column looping between two values, with a comma separator : 3001,3002,3003,3004,3005,3006,3007

Then I think I could probably explode the line with the comma separator. But I don't know how to create this list of value. Is that possible with Power Query Editor ? Any help will be much appreciated ! 🙂 

1 ACCEPTED SOLUTION
pceglie
Resolver I
Resolver I

Hi, you can use "range" in M language.

In your table you have to add a Custom column like this

pceglie_0-1689850458202.png

after that you will obtain a custom column and "Expand to new rows" on that column

pceglie_1-1689850532287.png

 

will produce the belowe result

pceglie_2-1689850584209.png

 

Now you can remove the "from" and "to" existing columns

pceglie_3-1689850628840.png

 

 

Hope will help

 

 

View solution in original post

3 REPLIES 3
pceglie
Resolver I
Resolver I

Hi, you can use "range" in M language.

In your table you have to add a Custom column like this

pceglie_0-1689850458202.png

after that you will obtain a custom column and "Expand to new rows" on that column

pceglie_1-1689850532287.png

 

will produce the belowe result

pceglie_2-1689850584209.png

 

Now you can remove the "from" and "to" existing columns

pceglie_3-1689850628840.png

 

 

Hope will help

 

 

Oh very cool, I didn't know this syntax. And the "expand" option, I didn't know either, thanks a lot !

In the mean time, I found another solution to get the range : "List.Numbers(Number.FromText([Postcode]),[RangeSize]+1)" (with the second value being the size of the range, I created a custom column to calculate the difference between the two codes). But your solution is even simpler. 

Ahmedx
Super User
Super User

Can you share sample data and sample output in table format?

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.