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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

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
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.