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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
hassanh2
Helper I
Helper I

Dynamic count of products bought by 'n' customers

Hello I have the following data set and need your help to get a measure that calculates the count of products that were bought by 'n' customers 

Column A: Product ID

Column B: Customer ID
Column C: Qty bought by customer

Column D : distinct count of customers who bought each product

Column E: Require DAX measure to calculate the distinct count of products that were bought by less than 'n' customers. 

 

hassanh2_1-1717964228640.png

 

 

1 ACCEPTED SOLUTION
lucadelicio
Super User
Super User

Hi @hassanh2 
the result pbix as attachments.
Mark as a solution if i help you!



Luca D'Elicio

LinkedIn Profile

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi, @hassanh2 

You can refer to @lucadelicio reply. If it does not work, you can try this.

vyaningymsft_1-1717986889320.png

vyaningymsft_0-1717986823033.png

Measure:

Counts = 
CALCULATE (
    COUNTROWS ( 'Table' ),
    FILTER (
        ALLEXCEPT ( 'Table', 'Table'[Product ID] ),
        'Table'[Qty] <> 0
    )
)
Product ID if less counts = 
VAR _getNumber =
    SELECTEDVALUE ( Number[Value] )
VAR _productId =
    SELECTEDVALUE ( 'Table'[Product ID] )
VAR _result =
    IF ( [Counts] < _getNumber, 1, 0 )
RETURN
    _result

 

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

lucadelicio
Super User
Super User

Hi @hassanh2 
the result pbix as attachments.
Mark as a solution if i help you!



Luca D'Elicio

LinkedIn Profile

Thank you so much .. this was very helpful and it gave me the required outcome.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

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.

Top Solution Authors
Top Kudoed Authors