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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
tondeli
Advocate I
Advocate I

Calculate customer count when they have bought more than 3 products per week.

I have sales data that includes columns:

  • date
  • week
  • customer_id
  • receipt_id
  • product_id
  • sales_pcs
  • sales_eur

 

I'd like to create a measure that calculates customer count (distinct) when customer have bought more than 3 products in a week. Also I'd like to visualize this measure with Card.

 

products per week = distinctcount(sales[product_id])/distinctcount(sales[week])

 

I created a table visualization that contains week, customer_id and products per week. I also can add filter to my visualization and filter products per week >=3. I can see from this table how many customer_ids match my filter. When I try to transform my visualization to Card I'll get total amount of customer_ids. Filter do not work.

 

I tried to create another measure.

 

customer count = calculate(distinctcount(sales[customer_id]);filter(sales;[products per week]>=3)) 

This one doesn't give any answer.

 

I think that my problem has something to do with the order of the calculations. Is there a way to manipulate this? Also is there anything wrong with my second measure and why it doesn't give any aswer?

 

I'll still try to google my problem and try to find aswer from this site aswell. But any advices will be most appreciated.

 

1 ACCEPTED SOLUTION
tondeli
Advocate I
Advocate I

Answering to my own question... Smiley LOL

 

I created a new column just to calculate how many products each customer has bought.

Products purchased = calculate(distinctcount(sales[product_id]);allexcept(sales;sales[customer_id]))/distinctcount(sales[week])
Customer count = calculate(distinctcount(sales[customer_id]);filter(sales;[Products purchased]>=3))

Everything works now!

View solution in original post

1 REPLY 1
tondeli
Advocate I
Advocate I

Answering to my own question... Smiley LOL

 

I created a new column just to calculate how many products each customer has bought.

Products purchased = calculate(distinctcount(sales[product_id]);allexcept(sales;sales[customer_id]))/distinctcount(sales[week])
Customer count = calculate(distinctcount(sales[customer_id]);filter(sales;[Products purchased]>=3))

Everything works now!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.