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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

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
Community Champion
Community Champion

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?

Nathaniel_C
Community Champion
Community Champion

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
Community Champion
Community Champion

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
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.