How do we Pass the multiple selected values of a Slicer inside DAX?

Let's say I have a table like this - [Orders]

Date        Amount  Category
12/12/2017  100      A
12/12/2017  200      B
12/12/2017  300      C
1/1/2018    400      A
1/1/2018    500      B

And I have a slicer for Category.

If only one single Value is selected, then a measure like this will work

CALCULATE(SUM(Orders[Amount]),FILTER(ALL(Orders), Orders[Category] = SelectedValue(Category))).

When more than one value is selected, how would you pass that inside the DAX Measure?

Upvotes: 5

Views: 32212

Answers (1)

Alexis Olson
Alexis Olson

Reputation: 40204

Try this:

= CALCULATE(SUM(Orders[Amount])
      FILTER(ALL(Orders), Orders[Category] IN VALUES(Category)))

In most situations, you should just be able to write SUM(Orders[Amount]) and Power BI will automatically do the filtering for you based on the slicer.

Upvotes: 12

Related Questions