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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Adnaniqb
Regular Visitor

Customer Count those purchased 1 of all pack

our company have 3 products and each product avaialble in 3 packs (100ML, 200ML, 300ML)

what I m trying do is to count the customers those purchased each 3 packs regardless of product. 

e.g.

customer 1 purchased each 3 pack of same product so PBI should count 1

customer 2 purchased each 3 product but only 1 pack so count = 0

hope my requirement is clear. 

 

below are 3 tables

and file Link

Capture.JPG

 

2 ACCEPTED SOLUTIONS
johnt75
Super User
Super User

Try

# customers bought all packs = 
VAR TotalPacks = COUNTROWS( ALL( 'Product'[Pack] ) )
VAR Result =
	COUNTROWS(
		FILTER(
			GROUPBY(
				SUMMARIZE(
					'Sales',
					'Customer'[Customer Code],
					'Product'[Pack]
				),
				'Customer'[Customer Code],
				"@num packs", SUMX( CURRENTGROUP( ), 1 )
			),
			[@num packs] = TotalPacks
		)
	)
RETURN
	Result

View solution in original post

Ahmedx
Super User
Super User

pls try this

 

Measure = 
COUNTROWS (
    FILTER (
        SUMMARIZE (
           'Sales',
            Sales[Customer Code],
            "Count",
                COUNTROWS (
                    DISTINCT (
                        SUMMARIZE (
                            FILTER ( 'Sales', [Value] > 0 ),
                            Sales[Customer Code],
                            'Product'[Product Name]
                        )
                    )
                )
        ),
        [Count] = 3
    )
)

 

Screenshot_1.png

View solution in original post

5 REPLIES 5
Ahmedx
Super User
Super User

pls try this

 

Measure = 
COUNTROWS (
    FILTER (
        SUMMARIZE (
           'Sales',
            Sales[Customer Code],
            "Count",
                COUNTROWS (
                    DISTINCT (
                        SUMMARIZE (
                            FILTER ( 'Sales', [Value] > 0 ),
                            Sales[Customer Code],
                            'Product'[Product Name]
                        )
                    )
                )
        ),
        [Count] = 3
    )
)

 

Screenshot_1.png

ThxAlot
Super User
Super User

Customer All Packs.pbix

 

ThxAlot_0-1689278377472.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LeanAndPractise(Everyday)


)



Thanks for the reply,

actually there was mistake in my file as all customer bought all packs. but in this linked file i corrected it. 

if you see below screen shot except customer 2 all customers purchased all packs. hence customer count should be 5, 

also i will be gradeful if you explain how this dax query works. 

thanks in advance. 

Capture1.JPG

 

First of all, clarify which is the case you expect, Customer 1 or 2?

ThxAlot_2-1689434731225.png

 

Case 1 is a bit more complex than 2.



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LeanAndPractise(Everyday)


)



johnt75
Super User
Super User

Try

# customers bought all packs = 
VAR TotalPacks = COUNTROWS( ALL( 'Product'[Pack] ) )
VAR Result =
	COUNTROWS(
		FILTER(
			GROUPBY(
				SUMMARIZE(
					'Sales',
					'Customer'[Customer Code],
					'Product'[Pack]
				),
				'Customer'[Customer Code],
				"@num packs", SUMX( CURRENTGROUP( ), 1 )
			),
			[@num packs] = TotalPacks
		)
	)
RETURN
	Result

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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