In this article, we will look at another important function, which is called FILTER and is used in conjunction with the CALCULATE function. This function does the same thing as we do when we try to filter the data in the table by the values in a certain column. That is, in other words, this function reduces the size of the table with which, in turn, the CALCULATE function will work.
=FILTER(< table >, < filter >)
< table >
The table we want to filter. Also, there can be an expression that returns a table as a result:
< filter >
A comparison expression that is executed for each row of the table. Here are the conditions for selecting values:
Let's see how it looks in practice. Suppose we have such a table, which is called
We need to count the number of records for a product
=CALCULATE(COUNTROWS(Demo); FILTER(Demo; Demo[Product]="Bikes"))
As a result, we will get the following values in the Count_All_Product field:
What did the FILTER function do? It reduced the size of the table, as we do in Excel by setting a filter in the column
Then she counted the number of all rows in the reduced table. We see that there are no entries in the Count_All_Product field in the other rows, because there are no skates in the new table