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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
tmv3v
Frequent Visitor

Frequency distribution from raw data

Currently say I have some sales data:

 

CustomerID ProductID CustomerCountry PricePaid

12345678 P1234567 US 300

12345678 P1234568 US 300

12345678 P1234569 US 300

12345670 P1234567 US 300

12345670 P1234568 US 300

12345672 P1234567 US 300

12345672 P1234568 US 300

12345671 P1234567 US 300

 

And I want a result table such that I want to count distinct on CustomerID and obtain the frequency distribution of the number of purchases:

 

NoOfPurchases NoOfCustomers

1 1

2 2

3 1

 

I am able to do this with SQL using temp tables then importing the temp tables into PowerBI but I am finding a way do achieve this in PowerBI directly from the raw data as all my tables are depending on the raw data table. I guess using only one data table will reduce the loading time too? Thanks!

1 ACCEPTED SOLUTION
rajulshah
Resident Rockstar
Resident Rockstar

Hello @tmv3v,

 

Please create a calculated column as follows:

Number of Purchases = CALCULATE(COUNT(Purchases[ProductID]),FILTER(ALL(Purchases),Purchases[CustomerID]=EARLIER(Purchases[CustomerID])))

 

Then, plot 'Number of Purchases' and CustomerId in a table visual.

Make sure to select 'Don't summarize' for 'Number of Purchases' and 'Count' for 'CustomerID'. See below:
dontsummarize.png

 

purchases.pngHope this helps.

View solution in original post

2 REPLIES 2
rajulshah
Resident Rockstar
Resident Rockstar

Hello @tmv3v,

 

Please create a calculated column as follows:

Number of Purchases = CALCULATE(COUNT(Purchases[ProductID]),FILTER(ALL(Purchases),Purchases[CustomerID]=EARLIER(Purchases[CustomerID])))

 

Then, plot 'Number of Purchases' and CustomerId in a table visual.

Make sure to select 'Don't summarize' for 'Number of Purchases' and 'Count' for 'CustomerID'. See below:
dontsummarize.png

 

purchases.pngHope this helps.

Hello @tmv3v,

If the solution helped you, then please mark the post as Solution so that it is easy for others in need.

 

Thanks. 🙂

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.