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
- Smartsheet Customer Resources
- 63.9K Get Help
- 410 Global Discussions
- 220 Industry Talk
- 458 Announcements
- 4.8K Ideas & Feature Requests
- 143 Brandfolder
- 137 Just for fun
- 57 Community Job Board
- 459 Show & Tell
- 31 Member Spotlight
- 1 SmartStories
- 298 Events
- 37 Webinars
- 7.3K Forum Archives