How to repeat rows in a new view based on integer column value

I have a base imported table with 2 columns.

Name Number
Bob 4
Phil 3

I need a new view/table that is based on the original imported table that would have the value of the Name column repeated Number times.

Name
Bob
Bob
Bob
Bob
Phil
Phil
Phil

Anyone have any tips on how to accomplish this in Grist? I’ve manually done it in Excel but its a pain.

Thanks!

Here is a rather hacky way:

https://public.getgrist.com/3jx3vnH2rivg/Repeat-Rows/m/fork

What it does is create a “Reps” column with the formula range(int($Number)) and with the type “ChoiceList”. It produces a list of values, as many as specified in the Number column.

Then another widget shows a summary table which groups the data using both “Name” and “Reps” columns. It includes a row for each combination of Name and a value from that generated list. So you get each name repeated Number times. You can hide the helper columns to make it prettier.

A big limitation is that the resulting summary table doesn’t hold data, only formulas. (Essentially that’s because rows may disappear from it when the original data changes.) So if you need to have other data associated with each repetition, you’d need to copy-paste the generated column of names into another table.

1 Like

I’ll give it a try, thanks!

For my use-case, thats likely okay. I just need to export the resulting data.

Any thoughts on how to tune it to handle a count of 0?

George should have no entries in the view.