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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
DonTwan
Regular Visitor

Calculating number of shops that sold at least N quantity of a single item

I have a sale table that looks like this:

BookingDateShopIdArticleIdQtyPieces
10/05/2023704788314526
10/05/2023704788308911
10/05/20237047883054410

 

And would like to know how many shops have sold at least 4 total quantity for each of the articles 

 

My matrix is setup as following 

 

DonTwan_0-1693844762991.png

the values are:

Distinct count of shops, sum of QtyPieces and Distinct count of shops where at least 4 of the article is sold.

 

 

CALCULATE( 
    DISTINCTCOUNT(F_Sales_22May23[ClientId]), 
    FILTER( 
        F_Sales_22May23, 
        SUM(F_Sales_22May23[QtyPieces])> 4 
        )
)

 

 

 

the result is

DonTwan_1-1693844793899.png


because the formulla evaluates for each filter context individually, the number of distinct shops = number of shops with at least 4 in quantity sales. 

 

DonTwan_2-1693845113797.png


How do i rewrite the formulla so the totals only count shops that have less than 4 Qty sales. 

 

 

 

 

1 REPLY 1
lbendlin
Super User
Super User

Instead of 

FILTER( 
        F_Sales_22May23, 
        SUM(F_Sales_22May23[QtyPieces])> 4 
        )

use

FILTER( 
        F_Sales_22May23, 
        [QtyPieces]> 4 
        )

or

F_Sales_22May23[QtyPieces]> 4 

 

Same with the <4 approach.

Helpful resources

Announcements
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.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

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