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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
oli6
Regular Visitor

How to do a count of count without aggregation

Hi,

 

  Here is my problem.

  I have this simple table below (Customer code and associated Order code) : 

 

Customer #Order #
C1O1
C1O2
C2O3
C3O4
C3O5
C3O6
C3O7
C4O8

 

From this, i want to calculate this : 

 

Number of customersNumber of orders
21
12
14

 

 In other words : we have 2 customers that have done only 1 order, only 1 customer with 2 orders and only 1 customer with 4 orders.

 

 And this will have to work with all dynamic filters in the report.

 

 Any idea on how to do this ?

 

Thanks !

1 ACCEPTED SOLUTION

The method I propose is dynamic and will work with any filters, slicers etc. The only static thing is the generated table for the numbers of orders, but as long as you create that to far exceed the possible number of orders then it shouldn't be a problem.

View solution in original post

5 REPLIES 5
oli6
Regular Visitor

Hi Jonht75,

 

  Thank you very much for your answer, that works nicely.

  Initialy, i wanted to generate automatically the table below : 

 

Number of customersNumber of orders
21
12
14

 

Do you think it is possible ?

 

That's the table which is generated as the GroupedTable variable in my code, but I don't see a way to get that into a table in a report.

Yes, that's my problem since the beginning. The request looks simple but it is not...

I was able to acheive this with calculated table, but it's generating a static table that will not work with filters in the document.

Thanks for you help anyway.

The method I propose is dynamic and will work with any filters, slicers etc. The only static thing is the generated table for the numbers of orders, but as long as you create that to far exceed the possible number of orders then it shouldn't be a problem.

johnt75
Super User
Super User

You could create a table to hold the possible numbers of orders just using GENERATESERIES and then put that in a visual with a measure like

Num customers by num orders = 
VAR SummaryTable =
	ADDCOLUMNS(
		SUMMARIZE( 'Table', 'Table'[Customer #] ),
		"@Num orders", [Num Orders]
	)
VAR GroupedTable =
	GROUPBY(
		SummaryTable,
		[@Num orders],
		"Num cust", SUMX( CURRENTGROUP( ), 1 )
	)
RETURN
	SELECTCOLUMNS(
		FILTER(
			GroupedTable,
			[@Num orders] = SELECTEDVALUE( 'Numbers of orders'[Value] )
		),
		"Num cust", [Num cust]
	)

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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