0
votes

I created a DAX Measure in Excel. I need to sum pieces sold for only certain products within one company. I created a Pivot table with Companies' codes in a column A. And created a DAX measure:

CALCUALTE(
SUM('Sales'[Sold,pieces]),
FILTER('Sales',
'Sales'[Product]="Apples"&&'Sales'[Product]="Peaches")
)

This Measure does not work for multiple products, but for one product works. Where is a mistake?

Please assist me. Thank you.

2

2 Answers

1
votes

I think that the problem is the boolean operator used in the measure. The && means AND, therefore the filter is checking for the product that are Apples AND Peaches. What we want instead are products that are Apples OR Peaches. The OR operator is the double pipleline: ||

CALCULATE (
    SUM ( 'Sales'[Sold,pieces] ),
    FILTER (
        'Sales',
        'Sales'[Product] = "Apples"
            || 'Sales'[Product] = "Peaches"
    )
)
-2
votes
CALCULATE (
SUM ('Sales'[Sold,pieces] ),
SWITCH ('Sales'[Product],
"Apples",TRUE(),
"Peaches",TRUE(),
FALSE()
))