Ever wanted to return a subset of a dataset rather than the whole thing? The FILTER function lets us sieve a table to extract only the desired rows based on criteria.
Check out this quick video to learn how to do this!
In the example, a table called tblProducts houses product data, and we want to return only the items that cost under Β£100.
This formula achieves the result:
=π΅πΈπ»ππ΄π(ππππΏπππππππ,
ππππΏπππππππ[πΏππππ (Β£)]<π·00
)
The table name is referenced in πππππ’ to return all columns, whilst the condition is specified in πππππππ to return all rows where the value in the Price column is less than 100.
The condition evaluates to an array of TRUE and FALSE values that represent the rows and indicate which ones to return:
{ππππ΄;π΅π°π»ππ΄;ππππ΄;ππππ΄;π΅π°π»ππ΄;π΅π°π»ππ΄;
ππππ΄;ππππ΄;π΅π°π»ππ΄;ππππ΄;ππππ΄;π΅π°π»ππ΄;π΅π°π»ππ΄;
π΅π°π»ππ΄;π΅π°π»ππ΄;π΅π°π»ππ΄;π΅π°π»ππ΄;π΅π°π»ππ΄;ππππ΄;ππππ΄}
Often, you're likely to require more than one criterion, though. The function provides no obvious way of doing this. However, there is a way:
=π΅πΈπ»ππ΄π(ππππΏπππππππ,(ππππΏπππππππ[πΏππππ (Β£)]<π·00)*(ππππΏπππππππ[ππππππ]>=πΊ))
Building on the same condition as the first example, an asterisk is added after, which is the multiplication operator representing AND criteria. The second condition then returns all rows with a value greater than or equal to 4 in the Rating column.
This calculation is taking place:
{π·;0;π·;π·;0;0;π·;π·;0;π·;π·;0;0;0;0;0;0;0;π·;π·}
*
{0;π·;π·;0;π·;0;0;π·;0;0;0;π·;0;0;0;π·;0;π·;π·;0}
Because two conditions are multiplied, the TRUE and FALSE array values are coerced into 1s and 0s. Multiplying by 0 is always 0, so both respective values must equal 1 for their row to be returned.
Finally, if using multiple conditions, be sure to enclose each one in brackets to avoid any unusual results.
Like this guide? Check out our Video Tutorials to discover other ways to power up your Excel skills!
Conversation
As you comment, let's keep the discussion friendly and respectful to add value to the conversation.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse varius enim in eros elementum tristique. Duis cursus, mi quis viverra ornare, eros dolor interdum nulla, ut commodo diam libero vitae erat. Aenean faucibus nibh et justo cursus id rutrum lorem imperdiet. Nunc ut sem vitae risus tristique posuere. uis cursus, mi quis viverra ornare, eros dolor interdum nulla, ut commodo diam libero vitae erat. Aenean faucibus nibh et justo cursus id rutrum lorem imperdiet. Nunc ut sem vitae risus tristique posuere.