Row Count - Counting in Repeating Intervals

Hello! I’ve been searching the forums to find a solution to my issue but I haven’t found one. If this question has been answered already, please point me to it.

Put simply, I have a dataset where 12 fields are being produced as rows rather than as columns. Meaning that the row count is many times larger than it should be. But the order is consistent. So I’d like a new column numbering the rows 1-12 in sequence to aid with pivoting them into columns. Essentially:

Row0 - 1
Row1 - 2
Row2 - 3
Row3 - 4
Row4 - 5
Row5 - 6
Row6 - 7
Row7 - 8
Row8 - 9
Row9 - 10
Row10 - 11
Row11 - 12
Row12 - 1
Row13 - 2

I suspect that a loop will be the solution. Since I know the final row count will be divisible by 12, it should be easy to calculate that into the total number of loops required and enter that as a flow variable. But I haven’t been able to figure out how to make the whole thing work. Hopefully, this all makes sense.

Thank you very much in advance. I hope the answer isn’t too embarrassingly obvious!

Hi @CKillick
If I understand you right, I think this will achieve what you need.

First Identify the x number of total rows
Divide it by 12 for the count number (y=x/12)
First a Loop y times through it using counting LoopStart.
Second a chunk LoopStart with a chunk of 12 through it.
Then a RowID, a transpose node and then two loop ends

Row count


Counting Loop Start

Chunk loop start



Loop end



Hi @CKillick , to get the required row number would a Math Formula with the below formula not achieve the desired result (and tick “Convert to Int”):



I wasn’t sure what you’d do for column names, but I guess they would just become 1 thru 12. Pivot into Lists and then ungroup should give you the rows

stack rows into columns.knwf (11.6 KB)

1 Like

Thank you both! I believe either of these solutions would work but I find the math formula a bit easier to deploy so I’ll probably proceed with that. But I’m glad that the solution was indeed simple.

Thanks again!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.