I have a list of books on Google Sheets that will be turned into a paged layout on InDesign. Each book has two additional information besides its title (year and theme).
Like this
But I need this list to be structured in a stacked way. Grouping first by year, and then by theme, like this (I've formatted the cells just to clarify):
I currently do this stacking manually, and it requires quite a lot of time. Is there some sort of formula, or tool, to solve this problem? I guess it can be done with scripting, but I wanted to know if there's a non-scripting way to do it before diving into Google sheets script documentation.
Best Answer
Formula
=ArrayFormula(TRANSPOSE(SPLIT(JOIN(",",IF(A2:A10=A1:A9,,"Year "&A2:A10)&","&C2:C10&","&IF(B2:B10=B1:B9,,B2:B10)),",")))
Explanation
A2:A10=A1:A9
.IF
returns a blank.&
concatenates values and functions results. We are using a comma as separator between IF results and the values ofC2:C10
.JOIN
joins the values of a1 x n
orn x 1
range. We are using a comma as separator.SPLITS
separate subtext of a text. We are using a comma as subtext delimiter.ArrayFormula
expands the result of the inner formula to range of the required size by the result.