HomeGoogle DocsSpreadsheetHow to Use IFS Function to Return an Array Result in Google...

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.

EXPAND + Stacking: Expand an Array in Excel

We can expand an array by adding values at the end using the EXPAND...

Convert Month Name to Days in Google Sheets

We can utilize the EOMONTH, MONTH, DATE, and DAY functions in Google Sheets to...

Creating Custom Descending Sequence Lists in Excel

You can utilize functions like ROW or SEQUENCE in Excel to create a custom...

SUMIFS with XLOOKUP in Excel and Google Sheets

SUMIFS and SUMIF are infamous for producing an "argument must be a range" error...

More like this

Convert Month Name to Days in Google Sheets

We can utilize the EOMONTH, MONTH, DATE, and DAY functions in Google Sheets to...

Appointment Schedule Template in Google Sheets

An appointment schedule template in Google Sheets can assist you in efficiently managing your...

Creating Sequential Dates in Equally Merged Cells in Google Sheets

Do you know how to create sequential dates in equally merged cells across 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.