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
fbron
Frequent Visitor

Measure Sum based on multiple conditions

Based on the data below id like to create a measure to calulate the sum of the coumn 'Quantity' with multiple conditions. 

Data ExampleData Example

 

For example, I'd like to know the total of column quantity for the orders with ordertype "0" and  orderstatus "on hold" and "open":

 

I already tried the following:

 

Total ongoing Ordertype 0 = CALCULATE(SUM(Order Table[Quantity]),

      FILTER(Order Table, Order Table[Ordertype]= "0"),

      FILTER(Order Table, Order Table[Order Status]= "Open"),

      FILTER(Order Table, Order Table[Order Status]= "On Hold")

)

 

Expected value would be 4 but somehow this doesnt show up. 

What am I doing wrong here? Any suggestions?

 

PS:

Ordertype (=column type "Whole Number")

Order status (=column type "Text")

Quantity (=column type "Decimal Number")

 

 

 

1 ACCEPTED SOLUTION
AlB
Community Champion
Community Champion

Hi @fbron 

If Ordertype (=column type "Whole Number") you ned to compare to a number, not to text

You are doing a logical AND for Open and On hold for Order status. That would mean you want it to be Open and On hold at the same time. You need an OR instead:

 

Total ongoing Ordertype 0 =
CALCULATE (
    SUM ( 'Order Table'[Quantity] ),
    'Order Table'[Ordertype] = 0,
    'Order Table'[Order Status] = "Open" || 'Order Table'[Order Status] = "On Hold"
)

or alternatively

Total ongoing Ordertype 0 =
CALCULATE (
    SUM ( 'Order Table'[Quantity] ),
    'Order Table'[Ordertype] = 0,
    'Order Table'[Order Status] IN  {"Open", "On Hold"}
)

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

 

View solution in original post

2 REPLIES 2
CNENFRNL
Community Champion
Community Champion

Hi, @fbron , why bother to hardcode those filtering conditions in a measure? Slicers with a simple measure do the trick with ease and with more flexibilities. Dax is born for such a scenario. An Excel file is attached for your reference.

Total Qty = SUM(Order Table[Quantity])

Slicers.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

AlB
Community Champion
Community Champion

Hi @fbron 

If Ordertype (=column type "Whole Number") you ned to compare to a number, not to text

You are doing a logical AND for Open and On hold for Order status. That would mean you want it to be Open and On hold at the same time. You need an OR instead:

 

Total ongoing Ordertype 0 =
CALCULATE (
    SUM ( 'Order Table'[Quantity] ),
    'Order Table'[Ordertype] = 0,
    'Order Table'[Order Status] = "Open" || 'Order Table'[Order Status] = "On Hold"
)

or alternatively

Total ongoing Ordertype 0 =
CALCULATE (
    SUM ( 'Order Table'[Quantity] ),
    'Order Table'[Ordertype] = 0,
    'Order Table'[Order Status] IN  {"Open", "On Hold"}
)

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors