google 表格中的空单元格从宽变长

going from wide to long with empty cells in google sheets

我正在尝试从宽到长两列,最后两列中的空白保留信息。

示例和预期效果请参见google sheets link

这可能有效:

=IF(ERROR(ARRAYFORMULA(split(FLATTEN(A2:B4&"!"&C2:C4&"!"&D2:D4),"!"))) = "FALSE" ,ARRAYFORMULA(split(FLATTEN(A2:B4&"!"&C2:C4&"!"&D2:D4), "!")))," ")

使用:

=INDEX(QUERY(SPLIT(FLATTEN(
 IF(A2:B5="",,A2:B5&"×"&C2:C5&"×"&D2:D5)), "×"), 
 "where Col2 is not null", ))