How to display a personalized message when I use a query-importrange in Sheets

血红的双手。 提交于 2021-02-05 08:18:12

问题


I'm using a query function with importrange but I need a personalized message when query couldn't find anything in the database. Currently I'm using this formula.

=QUERY(
  {
    IMPORTRANGE("url", "'Parte 1'!A1:AH");
    IMPORTRANGE("url", "'Parte 2'!A1:AH");
    IMPORTRANGE("url", "'Parte 3'!A1:AH");
    IMPORTRANGE("url", "'Parte 4'!A1:AH")
  }, "Select Col2, Col1, Col34, Col24, Col3, Col4, Col5, Col6, Col11, Col7, Col8, 
             Col9, Col10, Col12, Col13, Col14, Col15, Col20, Col21, Col22, Col23 
      Where Col10="&$C$1&" And Col22 != 'Duplicado'") 

回答1:


try:

=ARRAYFORMULA(QUERY({
 IFERROR(IMPORTRANGE("url", "'Parte 1'!A1:AH"), 
         {"1 not working", SUBSTITUTE(COLUMN(B:AH)^0, 1, )});
 IFERROR(IMPORTRANGE("url", "'Parte 2'!A1:AH"), 
         {"2 not working", SUBSTITUTE(COLUMN(B:AH)^0, 1, )});
 IFERROR(IMPORTRANGE("url", "'Parte 3'!A1:AH"), 
         {"3 not working", SUBSTITUTE(COLUMN(B:AH)^0, 1, )});
 IFERROR(IMPORTRANGE("url", "'Parte 4'!A1:AH"),
         {"4 not working", SUBSTITUTE(COLUMN(B:AH)^0, 1, )})}, 
 "select Col2,Col1,Col34,Col24,Col3,Col4,Col5,Col6,Col11,Col7,Col8,
         Col9,Col10,Col12,Col13,Col14,Col15,Col20,Col21,Col22,Col23 
  where Col10="&$C$1&" 
    and Col22 != 'Duplicado'
     or Col1 contains 'not working'"))


来源:https://stackoverflow.com/questions/60943048/how-to-display-a-personalized-message-when-i-use-a-query-importrange-in-sheets

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!