Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
alsm
Helper III
Helper III

calculate sum with multiple criteria

Hello

I have a table that somewhat looks like

IndustrySub-IndustryVolume
Energy Equipment & ServicesDrilling100
Energy Equipment & ServicesOil & Gas Equipment & Services150
Oil, Gas & Consumable FuelsDrilling50
Oil, Gas & Consumable FuelsIntegrated Oil & Gas75
Oil, Gas & Consumable FuelsOil & Gas Exploration & Production200
Metals & MiningDrilling225
Metals & MiningDiversified Metals & Mining90
Metals & MiningCopper75

 

I want to calculate sum with following filter criteria

Industry IN {Energy Equipment & Services, Oil, Gas & Consumable Fuels} and Sub-Industry = Drilling

OR

Industry IN {Metals & Mining} and Sub-Industry = 'Diversified Metals & Mining'

 

How to write this combination of AND and OR conditions in Calculate(Sum(Volume),..???..)

 

1 ACCEPTED SOLUTION
Nathaniel_C
Super User
Super User

Hi @alsm ,

There are many ways to write this, however this works:

Sum =
CALCULATE (
    SUM ( IndustryResearch[Volume] ),
    FILTER (
        IndustryResearch,
        IndustryResearch[Industry]
            IN { "Energy Equipment & Services", "Oil, Gas & Consumable Fuels" }
            && IndustryResearch[Sub-Industry] = "Drilling"
    )
)
    + CALCULATE (
        SUM ( IndustryResearch[Volume] ),
        FILTER (
            IndustryResearch,
            IndustryResearch[Industry] = "Metals & Mining"
                && IndustryResearch[Sub-Industry] = "Diversified Metals & Mining"
        )
    )


image.png


Let me know if you have any questions.

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos 👍are nice too.
Nathaniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

3 REPLIES 3
alsm
Helper III
Helper III

@Nathaniel_C Thank you for your reply, it works. I have a followup question (don't know if I should ask another question or simply here). Can I create a filter variable which has common filter criteria and then use this common filter + additional filter lines in each calculate rows?

Hi @alsm ,

 

Would you give me an example of what you mean?

 


Let me know if you have any questions.

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos 👍are nice too.
Nathaniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Nathaniel_C
Super User
Super User

Hi @alsm ,

There are many ways to write this, however this works:

Sum =
CALCULATE (
    SUM ( IndustryResearch[Volume] ),
    FILTER (
        IndustryResearch,
        IndustryResearch[Industry]
            IN { "Energy Equipment & Services", "Oil, Gas & Consumable Fuels" }
            && IndustryResearch[Sub-Industry] = "Drilling"
    )
)
    + CALCULATE (
        SUM ( IndustryResearch[Volume] ),
        FILTER (
            IndustryResearch,
            IndustryResearch[Industry] = "Metals & Mining"
                && IndustryResearch[Sub-Industry] = "Diversified Metals & Mining"
        )
    )


image.png


Let me know if you have any questions.

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos 👍are nice too.
Nathaniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

Top Solution Authors