IN

The IN function returns a table that represents the subset of a column made up of those rows that contain a value that belongs to a given set.

If a scalar is specified instead of a column, the function returns True if the scalar in question appears in the table of values or in the specified set of values.

Syntax

column IN table

Parameters
  • column: Column of a table whose values you want to analyze.
  • table: List of values to use in column filtering.
Returned value

This function returns a table made up of the column rows whose values are found in table .

Additional Information

As shown in the following example, this function -introduced in Power BI in November 2016- is equivalent to more complex DAX expressions in which filtering is done value by value.

Examples

Assuming the existence of a Sales measure that calculates the sum of product sales, we could calculate the sum of sales for products whose keys are 317, 318 and 319 using the following measure:

Product sold = CALCULATE(ResellerSales[Sales];
    'Product'[ProductKey] = 317
    || 'Product'[ProductKey] = 318
    || 'Product'[ProductKey] = 319
)

With the IN function, this same expression can be simplified as follows:

Product sold = CALCULATE(ResellerSales[Sales], ResellerSales[ProductKey] IN {317, 318, 319})

IN function. Example of use

In this other example we want to know if the country Spain -value that appears in the Country column of the Geography table- has been selected (regardless of the selection method):

Selected = "Spain" IN VALUES('Geography'[Country])

Category
Logical
Submitted by admin on Thu, 12/13/2018 - 13:10