I would like to know how to filter and join each row adding the header before the values addin a ":" beetween Header and Value and separating them with ";". If the value is blank the header don't have to be selected.
Gender
Female
Man
Category
XYZ
ABC
Weight
45
30
Elasticity
High
Medium
The result need to be:
Features
Category:XYZ;Weight:45;Elasticity:High
Gender:Female;Elasticity:Medium
Gender:Male;Category:ABC;Weigh:30
I'm playing with arrayformula, join and filter functions but I can't figured out how to "loop" to join header with values, maybe I simply don't know what function I have to use.
(If possibile I would like to avoid the use of Google Script)
Best Answer
Assuming your data is in the upper-left corner of a sheet, the following works (linebreaks added for readability):
Each
if
processes one column of data, prepending values by headers if the value is nonempty. The;
are inserted in between.The
regexreplace
perform a cleanup. The first one replaces any sequence of semicolons by a single semicolon. The second removes the semicolon at the beginning or end of string.Although it's tempting to try
join(";", ...)
here (which wouldn't require the cleanup), it can't handle a two-dimensional array of data.