• Skip to main content
  • Skip to header right navigation
  • Skip to site footer

My Online Training Hub

Learn Dashboards, Excel, Power BI, Power Query, Power Pivot

  • Courses
  • Pricing
    • Free Courses
    • Power BI Course
    • Excel Power Query Course
    • Power Pivot and DAX Course
    • Excel Dashboard Course
    • Excel PivotTable Course – Quick Start
    • Advanced Excel Formulas Course
    • Excel Expert Advanced Excel Training
    • Excel Tables Course
    • Excel, Word, Outlook
    • Financial Modelling Course
    • Excel PivotTable Course
    • Excel for Customer Service Professionals
    • Excel for Operations Management Course
    • Excel for Decision Making Under Uncertainty Course
    • Excel for Finance Course
    • Excel Analysis ToolPak Course
    • Multi-User Pricing
  • Resources
    • Free Downloads
    • Excel Functions Explained
    • Excel Formulas
    • Excel Add-ins
    • IF Function
      • Excel IF Statement Explained
      • Excel IF AND OR Functions
      • IF Formula Builder
    • Time & Dates in Excel
      • Excel Date & Time
      • Calculating Time in Excel
      • Excel Time Calculation Tricks
      • Excel Date and Time Formatting
    • Excel Keyboard Shortcuts
    • Excel Custom Number Format Guide
    • Pivot Tables Guide
    • VLOOKUP Guide
    • ALT Codes
    • Excel VBA & Macros
    • Excel User Forms
    • VBA String Functions
  • Members
    • Login
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member

How to create array of numbers from 1 row?|Power Query|Excel Forum|My Online Training Hub

You are here: Home / How to create array of numbers from 1 row?|Power Query|Excel Forum|My Online Training Hub

vba course banner

Avatar
sp_LogInOut Log In sp_Registration Register
sp_Search Search
Advanced Search
Search
Forum Scope




Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
sp_Search Search
sp_RankInfo
Lost password?
sp_CrumbsHome HomeExcel ForumPower QueryHow to create array of numbers from…
sp_PrintTopic sp_TopicIcon
How to create array of numbers from 1 row?
Avatar
jaryszek
Member
Members
Level 0
Forum Posts: 183
Member Since:
February 1, 2019
sp_UserOfflineSmall Offline
1
July 26, 2021 - 8:09 pm
sp_Permalink sp_Print

Hi Guys,

i have table like here:

Topology|Tier|TotalServers

Topology1 Tier1 4
Topology1 Tier2 2
Topology2 Tier3 3

as you can see there is TotalServers for each topology and tier. 

And now the expected result is:

Topology|TierServer|Number

Topology1 Tier1 1
Topology1 Tier1 2
Topology1 Tier1 3
Topology1 Tier1 4
Topology1 Tier2 1
Topology1 Tier2 2
Topology2 Tier3 1
Topology2 Tier3 2
Topology2 Tier3 3

 

so generally i want to break TotalServers into Servernumber when TotalServers is max and min =1. Something like list.generate from 1 to n where n is the TotalServers. 

Can anybody help?
Best,
Jacek

sp_AnswersTopicSeeAnswer See Answer
Avatar
Anders Sehlstedt
Eskilstuna, Sweden

VIP
Members


Trusted Members
Level 3
Forum Posts: 873
Member Since:
December 7, 2016
sp_UserOfflineSmall Offline
2
July 27, 2021 - 8:14 am
sp_Permalink sp_Print

Hello,

A similar question was asked in this post, for me the suggested approach works just fine, check if it works for you.

sp_AnswersTopicAnswer
Answers Post
Avatar
jaryszek
Member
Members
Level 0
Forum Posts: 183
Member Since:
February 1, 2019
sp_UserOfflineSmall Offline
3
July 27, 2021 - 6:51 pm
sp_Permalink sp_Print

Hi,

thank you.

Hmm i stucked a little. 

I tried example from link above and i finished with:

let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Building", type text}, {"Device", type text}, {"Ports", Int64.Type}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each Text.Repeat("z",[Ports])),
#"Split Column by Position" = Table.ExpandListColumn(Table.TransformColumns(#"Added Custom", {{"Custom", Splitter.SplitTextByRepeatedLengths(1), let itemType = (type nullable text) meta [Serialized.Text = true] in type {itemType}}}), "Custom"),
#"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Position",{{"Custom", type text}})
in
#"Changed Type1"

Screenshot_188.pngImage Enlarger

What i am missing?

Best,
Jacek

sp_PlupAttachments Attachments
  • sp_PlupImage Screenshot_188.png (204 KB)
Avatar
Velouria
London or thereabouts
Moderator
Members


Trusted Members

Moderators
Level 4
Forum Posts: 649
Member Since:
November 1, 2018
sp_UserOfflineSmall Offline
4
July 27, 2021 - 8:35 pm
sp_Permalink sp_Print

You could use something like this I think:

 

let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Building", type text}, {"Device", type text}, {"Ports", Int64.Type}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Counter", each {1..[Ports]}),
#"Expanded Counter" = Table.ExpandListColumn(#"Added Custom", "Counter")
in
#"Expanded Counter"

The following users say thank you to Velouria for this useful post:

Anders Sehlstedt
Avatar
Anders Sehlstedt
Eskilstuna, Sweden

VIP
Members


Trusted Members
Level 3
Forum Posts: 873
Member Since:
December 7, 2016
sp_UserOfflineSmall Offline
5
July 27, 2021 - 9:37 pm
sp_Permalink sp_Print

Hello,

Velouria's code gives a better result. But to answer your question, you got the expected result for that text split code, so nothing missed on your part. You got a new row for each z in the custom column, it is however not counting as what Velouria's code does.

Avatar
jaryszek
Member
Members
Level 0
Forum Posts: 183
Member Since:
February 1, 2019
sp_UserOfflineSmall Offline
6
July 27, 2021 - 10:57 pm
sp_Permalink sp_Print

Hi,

 

thank you very much.

It is working. 
Ok so the link above is not doing the right solution? 

One question:

{1..[Ports]} what these ".." means within list? 
Best,
Jacek

Avatar
Philip Treacy
Admin
Level 10
Forum Posts: 1530
Member Since:
October 5, 2010
sp_UserOfflineSmall Offline
7
July 28, 2021 - 9:17 am
sp_Permalink sp_Print

hi Jaryszek,

The .. in {1..[Ports]} means include all numbers from 1 to [Ports]

Further reading Power Query Lists • My Online Training Hub

regards

Phil

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Orlando Menes, Alicia Greynolds
Guest(s) 9
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 873
Purfleet: 414
Frans Visser: 346
David_Ng: 306
lea cohen: 222
Jessica Stewart: 218
A.Maurizio: 202
Aye Mu: 201
jaryszek: 183
Newest Members:
Blair Gallagher
Brandi Taylor
Hafiz Ihsan Qadir
Gontran Bage
adolfo casanova
Annestine Johnpulle
Priscila Campbell
Jeff Mikles
Aaron Butler
Maurice Petterlin
Forum Stats:
Groups: 3
Forums: 24
Topics: 6369
Posts: 27852

 

Member Stats:
Guest Posters: 49
Members: 32359
Moderators: 3
Admins: 4
Administrators: Mynda Treacy, Philip Treacy, Catalin Bombea, FT
Moderators: MOTH Support, Velouria, Riny van Eekelen
© Simple:Press —sp_Information

Sidebar

Blog Categories

  • Excel
  • Excel Charts
  • Excel Dashboard
  • Excel Formulas
  • Excel PivotTables
  • Excel Shortcuts
  • Excel VBA
  • General Tips
  • Online Training
  • Outlook
  • Power Apps
  • Power Automate
  • Power BI
  • Power Pivot
  • Power Query
microsoft mvp logo
trustpilot excellent rating
Secured by Sucuri Badge
MyOnlineTrainingHub on YouTube Mynda Treacy on Linked In Mynda Treacy on Instagram Mynda Treacy on Twitter Mynda Treacy on Pinterest MyOnlineTrainingHub on Facebook
 

Company

  • About My Online Training Hub
  • Disclosure Statement
  • Frequently Asked Questions
  • Guarantee
  • Privacy Policy
  • Terms & Conditions
  • Testimonials
  • Become an Affiliate

Support

  • Contact
  • Forum
  • Helpdesk - For Technical Issues

Copyright © 2023 · My Online Training Hub · All Rights Reserved. Microsoft and the Microsoft Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries. Product names, logos, brands, and other trademarks featured or referred to within this website are the property of their respective trademark holders.