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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
Marcin82
Frequent Visitor

Simple measure prolbem

I got two tables. One Is OrderNumber (with distinct values) and second is Sales Order Items. I built a matrix with order number from OrderNumber and itemnumber from Sales Order Items. One order can have many items of course. At every row of the the matrix I just want to have a number of items for this order. I needed to remove filter from order item column so as it 

CALCULATE(
COUNT(
Sales_order_item[item_id]),
ALL(Sales_order_item[item_id]
)
)
But the measure completely destroys the matrix. Now, under every order I see all possible items. Why is that??? 
4 REPLIES 4
Manoj_Nair
Solution Supplier
Solution Supplier

@Marcin82- Hi, try using ALLEXCEPT instead of ALL. The ALLEXCEPT function will keep all context filters except for those specified, so it will maintain the order context while calculating the item count.

 

ItemCount = 
CALCULATE(
    COUNT(Sales_order_item[item_id]),
    ALLEXCEPT(Sales_order_item, Sales_order_item[OrderNumber])
)

 

If this post helps to find solution would be happy if you could mark my post as a solution and give it a thumbs up

Best regards

Manoj Nair
Linkedin - https://www.linkedin.com/in/manoj-nair-%E2%98%81-344666104/

Doesn't work. I still see all possible items under order. My measure works when orderNumber is from same table as item. If it comes from "higher level" table (one side realtion) it shows all items under order.  SImple need huge problem in DAX, as always. 

Dhairya
Solution Supplier
Solution Supplier

Hey @Marcin82 
Can you please share your sample dataset and expected output so that I can help you with an accurate solution.

I would like to have only relevant items under order with count of all of them. 
I achieved it when I add VALUES(OrderNo) from OrderItems table as a CALCULATE argument . But why I get such a mess without it? There is a filter in the context from OrderNumber (but from other table). It should still be kept. Measure only removes filter on items. 

 

 

 

Zrzut ekranu 2023-06-28 233425.png

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.