Forum Discussion

mlmagl14's avatar
mlmagl14
Helper I
3 years ago
Solved

Pulling multiple results from one column

I have a sales report and one of the columns list all our vendors. I'd like to calculate the total profit of two of the vendors, but I don't know how to enter the correct dax to pull more than one vendor from the vendor column.

 

I can get the result with 1 vendor, but how do I add a second one? I used this formula to get the profit sum from one of the vendors:

Gross Profit = CALCULATE(SUM('Table'[Profit]),'Table'[Product Vendor]= "Vendor1" 

 

Thanks in advance. 

 

  • mlmagl14 ,

    The double pipe is used as an "OR" condition.  Please try something like this:

    Gross Profit = CALCULATE(SUM('Table'[Profit]),
                             FILTER( Table, 'Table'[Product Vendor] = "Vendor 1" ||
                                      'Table'[Product Vendor] = "Vendor 2" ))
    

    If you have multiple Vendors, you can also make use of the "IN" function.

    Hope this helps.

    Regards,

2 Replies

  • rsbin's avatar
    rsbin
    Community Champion

    mlmagl14 ,

    The double pipe is used as an "OR" condition.  Please try something like this:

    Gross Profit = CALCULATE(SUM('Table'[Profit]),
                             FILTER( Table, 'Table'[Product Vendor] = "Vendor 1" ||
                                      'Table'[Product Vendor] = "Vendor 2" ))
    

    If you have multiple Vendors, you can also make use of the "IN" function.

    Hope this helps.

    Regards,