Batching sequential rows that are "like groups" with a formula
Here's what I want to do. Column A has values that I want to group by rows, as shown in Column B. So the first group of "x" rows is a "1", the second group of "y" rows is a "2", alternating as shown.
This is a lot of data so I can't have infinite helper columns.
Best Answers
-
Add the following columns:
Title: Row ID (system column Auto-Number)
Title: ROW# Formula: =MATCH([Row ID]@row, [Row ID]:[Row ID], 0)
Title: Value (Column A in your description)
Title: First Group Formula: =IF([ROW#]@row = 1, 1, IF(INDEX(Value:Value, [ROW#]@row - 1) = Value@row, 0, 1))
Title: Group Number Formula: =COUNTIFS([First Group]:[First Group], @cell = 1, [ROW#]:[ROW#], @cell <= [ROW#]@row)
-
Answers
-
Add the following columns:
Title: Row ID (system column Auto-Number)
Title: ROW# Formula: =MATCH([Row ID]@row, [Row ID]:[Row ID], 0)
Title: Value (Column A in your description)
Title: First Group Formula: =IF([ROW#]@row = 1, 1, IF(INDEX(Value:Value, [ROW#]@row - 1) = Value@row, 0, 1))
Title: Group Number Formula: =COUNTIFS([First Group]:[First Group], @cell = 1, [ROW#]:[ROW#], @cell <= [ROW#]@row)
-
That's the direction I was heading -- the last column doesn't get me there, however. I tried to sum all the First Group at or prior to the current row with this formula: =SUMIF([First Group]:[First Group], [ROW#]:[ROW#] <= [ROW#]@row)
However, that just populated the column with the sum of every group (17).
-
-
Must have been a syntax or cache issue. In the end I just updated the sumif to sumifs (below), that worked. I then went and retried yours, which worked as well. Thanks for the help!
=SUMIFS([First Group]:[First Group], [ROW#]:[ROW#], <= [ROW#]@row)
-
Curious why use the ROW# vs just the Row ID? I was able to get both to work.
-
ROW# will update even if you move around the rows...
-
Ah, got it. If I have a unique serial number for each line I can use that as well. Thanks!
-
Yes that would work
Categories
- All Categories
- 14 Welcome to the Community
- Customer Resources
- 64.9K Get Help
- 441 Global Discussions
- 139 Industry Talk
- 471 Announcements
- 4.9K Ideas & Feature Requests
- 129 Brandfolder
- 148 Just for fun
- 68 Community Job Board
- 496 Show & Tell
- 33 Member Spotlight
- 2 SmartStories
- 300 Events
- 36 Webinars
- 7.3K Forum Archives