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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Calculate sum of column 1 where column 2 = value A or value B but not value C or value D

I am trying to write DAX to calculate the sum of column Quantity where column Age equals value A or value B but not where it equals value C or value D. 

 

I know how to calculate the sum for one value, but I can't figure out to calculate based on two values. 

 

For one condition, I have: 

 

NUMERATOR2 = CALCULATE(SUM(Part4[Quantity]), Part4[Age] = "DSP 0-63")
 
My Table looks as so:
 Table: Part 4
QuantityAge
5DSP 0-63
5DSP 0-63
5DSP 64-126
5DSP 64-126
5DSP 127-200
5DSP 127-200
5DSP +200
5DSP +200
 
I need to calculate the sum of Quantity where Age = DSP 0-63 or DSP 64-126. 
 
Thanks! 
1 ACCEPTED SOLUTION
ChrisMendoza
Resident Rockstar
Resident Rockstar

@Anonymous -

This seems to work:

Measure =
CALCULATE (
    SUM ( 'Part 4'[Quantity] ),
    FILTER (
        'Part 4',
        'Part 4'[Age] = "DSP 0-63"
            || 'Part 4'[Age] = "DSP 64-126"
    )
)





Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

Proud to be a Super User!



View solution in original post

4 REPLIES 4
ChrisMendoza
Resident Rockstar
Resident Rockstar

@Anonymous -

This seems to work:

Measure =
CALCULATE (
    SUM ( 'Part 4'[Quantity] ),
    FILTER (
        'Part 4',
        'Part 4'[Age] = "DSP 0-63"
            || 'Part 4'[Age] = "DSP 64-126"
    )
)





Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

Proud to be a Super User!



Anonymous
Not applicable

Thanks! This only gives me the total for DSP 0-63. I need the total for DSP 0-63 + DSP 64-126

@Anonymous -

I do not understand what you mean.

1.PNG






Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

Proud to be a Super User!



Anonymous
Not applicable

Never mind.  I did a hard refresh, and everything works. Thank you! 

 

Marie 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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