在Google Sheets或Excel中拆分:基于条件



我有这个谷歌电子表格。

-产品名称列的格式已经很好。完整单词,用"+"分隔。

-第二列表示产品名称中有字符串或Sugar的一部分。

-第三列是一些以良好格式重新格式化的产品(全名和"+"(

Product name           Sugar_word_in_product_name       Product reformated 
Choco + sug,oil                   1                     Choco + Sugar + oil         
Tablets + Sofa                    0
Television + table                0
sugar,oil,ingred                  1                     Sugar + oil + ingredients   

我想以这种格式返回。成分1,成分2…

Product name           Sugar_word_in_product_name       Product reformated            Ingredients1     Ingredients2     Ingredients3
Choco + sug,oil                   1                     Choco + Sugar + oil             Choco             Sugar           oil
Tablets + Sofa                    0                                                     Tablets           Sofa
Television + table                0                                                     Television        Table
sugar,oil,ingred                  1                     Sugar + oil + ingredients       Sugar             Oil            Ingredients
0

因此,基本上,我想将"Sugar_word_in_product_name"列中的"1"从"产品重新格式化"中分离出来

如果它是"0",我想从"产品名称"拆分成列。

这有一个条件。=IF(G2=0,SPLIT(F2,"+")).

这是我开始的查询,但不确定如何使其工作,并且在没有值时返回空白单元格

=IF(G2=0,SPLIT(F2,"+",IF(G2=1,SPLIT(H2,"+"))))

try:

=ARRAYFORMULA(IFERROR(IF(B2:B=1; SPLIT(C2:C; "+"); SPLIT(A2:A; "+"))))

最新更新