if-statementgoogle-sheetsarray-formulasnested-ififs

Using IFS with Arrayformula function in Google Sheets


I was wondering if its possible to use an IFS function inside the arrayfunction?

Im looking to have a drop down list populate an array depending on what is selected in the data validation.

the formula im using is:

=ARRAYFORMULA(IFs(H2="1st Quarter",'Pool 1 data'!C4:AG34,H2="2nd Quarter",'Pool 1 data'!C38:AG68,H2="3rd Quarter",'Pool 1 data'!C72:AG102,H2="4th Quarter",'Pool 1 data'!C106:AG136))

H2 is the drop down validation. So when "1st Quarter" is selected I want it to return the range c4:AG34, and when "2nd Quarter" is selected to return the range C38:AG68 and so on.

The current formula doesn't return anything. Am I way off or is there a different approach to make this happen?

Any advice would by greatly appreciated!

EDIT: Here is the link to the spreadsheet

https://docs.google.com/spreadsheets/d/1fIRpI_f76ac4VNcpp0Ffvx_68lRLjFtaPrYFdgFEDs0/edit?usp=sharing


Solution

  • use:

    =ARRAYFORMULA(
     IF(H2="1st Quarter",'Pool 1 data'!C4:AG34, 
     IF(H2="2nd Quarter",'Pool 1 data'!C38:AG68, 
     IF(H2="3rd Quarter",'Pool 1 data'!C72:AG102,
     IF(H2="4th Quarter",'Pool 1 data'!C106:AG136, )))))
    

    see: https://webapps.stackexchange.com/a/124685/186471

    you may think that the behavior of IFS() is similar to IF() and the reason of having IFS() is to avoid nesting of multiple IF() but that's not so true. Yes, there are some common baselines however, there is a major difference when it comes to arrays. IFS() in a combination of arrayed output expects arrayed input - that's why you got returned single-cell output instead of arrayed output.