Home > Software design >  Having REPT function iterate over multiple values
Having REPT function iterate over multiple values

Time:12-24

Hi I'm curious if this is even possible and just thought I'd throw it out.

I have this function in google sheets:

=ArrayFormula(TRIM(TRANSPOSE(SPLIT(QUERY(REPT(UNIQUE('Data Validation'!B3)&",",'Data Validation'!C3),,999^99),","))))

It allows me to specify the thing I want repeated as well as the number of times I want it repeated. Both of those are found in my data validation sheet which contains the following:

enter image description here

I am curious if there is a way to build the array formula so it essentially says:

repeat each element in column B the corresponding number of times in column C

Or in other words repeat EVP Sales 380 times then in the same output column repeat VP Inside Payments 36 times etc.

I haven't found anything remotely related to this online.

Thanks!

CodePudding user response:

The formula you are using is already built for that scenario, just supply the needed range to calculate it properly

Formula:

=ArrayFormula(TRIM(TRANSPOSE(SPLIT(QUERY(REPT(UNIQUE('Data Validation'!B2:B4)&",",'Data Validation'!C2:C4),,999^99),","))))

Output:

output

  • Related