Dynamic Array formula for listing item N times

deLockloire

Board Regular
Joined
Apr 4, 2008
Messages
116
Office Version
  1. 365
Platform
  1. Windows
Hi,

Have two tables. One contains processes. All processes have a unique ID (in column A), and a number of steps as instructions (each instruction step has its own column) that can range from 0 to 20. I.e., for each process, there can be 0 to 20 steps that needs to be followed. The table also has a column that counts the number of instruction steps the given process has (if you need that). E.g.,

IDStep1Step2Step3Step4Step5Step6TOTAL STEPS
PRC1Text of step 1 of PRC1.Text of step 2 of PRC1.2
PRC2Text of step 1 of PRC2.Text of step 2 of PRC2.Text of step 3 of PRC2.Text of step 4 of PRC2.Text of step 5 of PRC2.5

In the other table, I'd like to list the IDs of all processes in the first table N times where N = the number of instructions steps the given process has. So, for instance, in the above case, this is what I'd like as a result (preferably with a dynamic array formula, because table 1 will grow (it is also an excel table; i.e., CTRL+T).

PRC IDs
PRC1
PRC1
PRC2
PRC2
PRC2
PRC2
PRC2
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
As you are using Excel 365 and your data is in Excel table (with headers: ID and TOTAL STEPS resp.) try:
Excel Formula:
=TEXTSPLIT(TEXTJOIN("",TRUE,REPT(Table1[ID]&";",Table1[TOTAL STEPS])),,";",TRUE)
 
Upvote 1
Solution
Assuming your data (headers) start in A1

Excel Formula:
=LET(z,H2:H3,TOCOL(IFS(SEQUENCE(,MAX(z))-1<z,A2:A3),3))
 
Upvote 0
Another option
Fluff.xlsm
ABCDEFGHIJ
1IDStep1Step2Step3Step4Step5Step6TOTAL STEPS
2PRC1Text of step 1 of PRC1.Text of step 2 of PRC1.2PRC1
3PRC2Text of step 1 of PRC2.Text of step 2 of PRC2.Text of step 3 of PRC2.Text of step 4 of PRC2.Text of step 5 of PRC2.5PRC1
4PRC2
5PRC2
6PRC2
7PRC2
8PRC2
Sheet6
Cell Formulas
RangeFormula
J2:J8J2=TOCOL(IF(B2:G100<>"",A2:A100,1/0),2)
Dynamic array formulas.
 
  • Like
Reactions: JEC
Upvote 1
As you are using Excel 365 and your data is in Excel table (with headers: ID and TOTAL STEPS resp.) try:
Excel Formula:
=TEXTSPLIT(TEXTJOIN("",TRUE,REPT(Table1[ID]&";",Table1[TOTAL STEPS])),,";",TRUE)
This gives me a #VALUE error. However, it might be important (as it seems to be causing the trouble) that some processes might have 0 instructions. In each of those rows, the textjoin gives an error, which results in an overall #VAULE result.
 
Upvote 0
Assuming your data (headers) start in A1

Excel Formula:
=LET(z,H2:H3,TOCOL(IFS(SEQUENCE(,MAX(z))-1<z,A2:A3),3))
This seems to give as many repetitions of EVERY IDs as the largest number of steps ANY ID has.
 
Upvote 0
Another option
Fluff.xlsm
ABCDEFGHIJ
1IDStep1Step2Step3Step4Step5Step6TOTAL STEPS
2PRC1Text of step 1 of PRC1.Text of step 2 of PRC1.2PRC1
3PRC2Text of step 1 of PRC2.Text of step 2 of PRC2.Text of step 3 of PRC2.Text of step 4 of PRC2.Text of step 5 of PRC2.5PRC1
4PRC2
5PRC2
6PRC2
7PRC2
8PRC2
Sheet6
Cell Formulas
RangeFormula
J2:J8J2=TOCOL(IF(B2:G100<>"",A2:A100,1/0),2)
Dynamic array formulas.
This is ingenious, but If I also needed to add a couple of multipliers, i.e., N needs to be multiplied by X, a value pulled from, for instance, AA1, how would I do that? So in this example, if AA1 is 3, I would need 6 "PRC1"s and 15 "PRC2"s.
 
Upvote 0
You would need to use the approach that JEC used, but make sure that all the numbers in col H are real numbers & not text.
 
Upvote 0
that some processes might have 0 instructions. In each of those rows, the textjoin gives an error, which results in an overall #VAULE result.

But the formula from post #2 works well if there will be 0 in TOTAL STEPS column.
I mean number (digit) 0, not just "" obtained as a result of function. Note that "" looks the same to us, but for Excel is different than a really empty cell, which would be equivalet to 0 in that case.
 

Attachments

  • Zrzut ekranu 2024-07-16 082308.png
    Zrzut ekranu 2024-07-16 082308.png
    50.5 KB · Views: 4
Upvote 1

Forum statistics

Threads
1,221,689
Messages
6,161,300
Members
451,695
Latest member
Doug Mize 1024

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top