How to Use IFS Function to Return an Array Result in Google Sheets

Published on

Array result means result in a range instead of in a single cell. In some cases, we can use the IFS function to return an array result in Google Sheets.

To evaluate multiple conditions (criteria), we can use IF, SWITCH, or IFS. IF, which is so popular among these functions, requires nesting (multiple IF functions combined) that makes it look complicated.

Must Read: How to Use IFS Logical Function in Google Sheets [Also Nested IF].

The latter two functions are easy to use but lack at some point when compared to IF. That’s in the ability to return an array result.

In this post, I am going to elaborate on how to use the IFS function to return an array/range result in Docs Sheets. What else? I will also explain the alternative solution to return an array result when IFS fails.

Of course, we should only think about the IFS alternative, if we feel the IF nesting is tough to code and read later.

IFS Function to Return Result in a Range in Google Sheets

I have two examples.

  1. To show how to use IFS logical function to return an array result in Google Sheets.
  2. The other example is to show you where the IFS fails to return a range result.

In the second option, to replace IFS, we can use nested IF or Vlookup. Vlookup? Yes! It’s also an option.

IFS Function That Correctly Returns an Array Result in Google Sheets

Straightaway to one formula example.

I have the names of the days of week entered in a range as below.

Sunday
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday

Assume, these are entered in the range A1:A7 in Google Sheets. What I want is to return 1 for Sunday, 2 for Monday, 3 for Tuesday and so on.

Here is the IFS array formula.

=ArrayFormula(ifs(A1:A7="Sunday",1,A1:A7="Monday",2,A1:A7="Tuesday",3,A1:A7="Wednesday",4,A1:A7="Thursday",5,A1:A7="Friday",6,A1:A7="Saturday",7))
IFS function that returns an array result in Google Sheets

When we use IFS function to return an array result as above, we may face one issue. What’s that?

Assume if one of the logical expression is FALSE. As an example delete the value in cell A3. We can see that the formula returns N/A error in cell B3. It’s because, unlike IF, IFS doesn’t contain the value_if_false argument.

There are two methods to overcome this drawback in IFS which I have detailed in one of my earlier guide – How to Return Value When The Logical Expression is FALSE in IFS.

Here in our above example, we can execute the value_if_false argument as below.

=ArrayFormula(ifs(A1:A7="Sunday",1,A1:A7="Monday",2,A1:A7="Tuesday",3,A1:A7="Wednesday",4,A1:A7="Thursday",5,A1:A7="Friday",6,A1:A7="Saturday",7,1=1,"?"))

Simply replace the question mark (see the end part of the formula) with the value you want.

If the value you want to return is a string, keep the double-quotes, else if it’s a number remove the double-quotes.

Similar to number, if the FALSE part in IFS is a date or time, use the functions DATE or TIME respectively.

Example:

=ArrayFormula(ifs(A1:A7="Sunday",1,A1:A7="Monday",2,A1:A7="Tuesday",3,A1:A7="Wednesday",4,A1:A7="Thursday",5,A1:A7="Friday",6,A1:A7="Saturday",7,1=1,date(2019,8,28)))

If it’s a time it should be entered in the format – TIME(hour, minute, second).

Google Sheets IFS Formula Fails to Return a Range

Let me show you one instance where the IFS fails to return a range result. Assume you want to evaluate one value and if evaluates to TRUE, return two or more values.

Example:

The value to evaluate in cell A1 is a string which is “Saturday”.

=IF(A1="Saturday",{"Half Day for Batch 1","Leave for Batch II"})

This IF formula in cell B1 will return an array result in cell B1 and C1.

IFS function does not return a range

But the following IFS formula will only return the value “Half Day for Batch 1”.

=IFS(A1="Saturday",{"Half Day for Batch 1","Leave for Batch II"})

No matter whether we use ArrayFormula function with it as below.

=ArrayFormula(IFS(A1="Saturday",{"Half Day for Batch 1","Leave for Batch II"}))

The IFS formula miserably fails to return an array result here. I don’t want to use IF here. Is there any alternative solution?

Vlookup can replace IFS in the above example.

Vlookup as an Alternative to IFS Range Output

Formula:

=ArrayFormula(vlookup(A1,{A1,"Half Day for Batch 1","Leave for Batch II"},{2,3},0))

In real-life use, to simplify the above Vlookup, we can call the range from outside (as cell reference).

Vlookup as an alternative to IFS array output

Related Reading: How to Correctly Use AND, OR Functions with IFS in Google Sheets.

Prashanth KV
Prashanth KV
Your Trusted Google Sheets and Excel Guide Prashanth KV brings a wealth of experience in Google Sheets and Excel, cultivated through years of work with multinational corporations in Mumbai and Dubai. As a recognized Google Product Expert in Docs Editors, Prashanth shares his expertise through insightful blogging since 2012. Explore his blog for practical tips and guidance on maximizing your spreadsheet skills.

Sort Data but Keep Blank Rows in Excel and Google Sheets

Using a dynamic array formula or the FILTER command, we can sort data and...

Lookup Values Under Categories in Excel and Google Sheets

We can use a combination of XLOOKUP and VLOOKUP in both Excel and Google...

Extract Items Under a Category from the Same Column in Excel

In Excel, you can use a combination of the XLOOKUP and DROP functions to...

How to Create a Searchable Table in Excel Using the FILTER Function

Finding specific records, or rows containing the required information, is straightforward in Excel using...

More like this

XMATCH Row by Row: Finding Values Across a Range in Google Sheets

Using the BYROW function with XMATCH in Google Sheets allows us to match values...

Limit Formula Expansion to a Specific Row in Google Sheets

In this tutorial, I’ll explain how to limit the expansion of an array formula...

3-D Referencing Structured Data Tables in Google Sheets

When you have several tables within a single sheet—not across multiple sheets in a...

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.