Create List off of REPT function

2 followers
0
Avatar

I am looking to create a new row based on a product being purchased 3 times in a transaction. So current record has product code with a quantity of 3 but I need each quantity on its own line/record. I feel like if I can get the REPT converted to list format then I could use the EXPAND function to accomplish the 3 individual rows/records.

Any ideas how to get REPT string results into a list?

example: REPT string result = 243074622430746224307462

desired result = [24307462,24307462,24307462]

Jerry Johnson

4 comments

  • Avatar
    Joel Stewart

    Is the REPT string just all one big integer that repeats a pattern 3 times? Does it always repeat exactly 3 times or could it be more or less? 

    0
  • Avatar
    Jerry Johnson

    The REPT result will be repeated depending on the factor of how many items were purchased, So it could be more or less. The example I provided was when 3 were purchased.

    0
  • Avatar
    Joel Stewart

    Is the product code always 8 digits long? I'm just looking to determine an easy pattern to be able to split the text. 

    One consideration I have is to append a unique character to the end of the product code (i.e. a space character) so the text after the REPT function would be "24307462 24307462 24307642 ". With this output, you could use the TOKENIZELIST function to separate the string into a list based on the space character separators.

    Does this meet your needs? 

    0
  • Avatar
    Jerry Johnson

    It turns out I that the EXPLODE_RANGE function provides the results I am looking for. It 

    EXPLODE_RANGE(1;#Quantity).  which replicate records based on Quantity number.

    0
Please sign in to leave a comment.