Power BI: Create Measure and Filter on Multiple Values


You can use the following syntax in DAX to create a measure that filters rows based on multiple values:

Sum of Points = 
CALCULATE ( SUM ( 'my_data'[Points] ), 'my_data'[Team] IN { "A", "C" } )

This particular example creates a new measure named Sum of Points that calculates the sum of the values in the Points column only for the rows where the Team column is equal to either A or C.

The following example shows how to use this syntax in practice.

Example: Create Measure and Filter on Multiple Values in Power BI

Suppose we have the following table in Power BI named my_data that contains information about various basketball players:

Suppose we would like to calculate the sum of values in the Points column only for the players who have a value in the Team column of A or C.

To do so, click the Table tools tab and then click the New measure icon:

Then type the following formula into the formula bar:

Sum of Points = 
CALCULATE ( SUM ( 'my_data'[Points] ), 'my_data'[Team] IN { "A", "C" } )

Power BI filter multiple values

We can view this measure by switching to the Report View and inserting a card visualization that displays the value of the measure:

We can see that the sum of points for the players who are on either team A or C is 259.

Note: In this example we filtered based on two values, but you can filter using even more values by simply including more values in the curly brackets following the IN statement.

Additional Resources

The following tutorials explain how to perform other common tasks in Power BI:

How to Count Number of Occurrences in Power BI
How to Write an IF Statement in Power BI
How to Use “If Contains” Formula in Power BI

Leave a Reply

Your email address will not be published. Required fields are marked *