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
binerdy
Frequent Visitor

Sum against count group

Hi,

I've a fact table of sales data where I have customerKey , saleAmount and date in each record.

customerKey may repeat for sale transactions in a period.

Now I want to calculate sum of saleAmount against count of customers divided into groups.

for example,

Count of Customer1 in sale table =3

Count of Customer2 in sale table = 5

Count of Customer3 in sale table = 8

Count of Customer4 in sale table= 4

Count of Customer5 in sale table = 2

 

count groups are 1-5, 6-10, 11-15

I need total sum of saleAmount that is calculated on the count of customer falling in above groups.

I've tried multiple solution but sum against count groups can't be achieved. Help will be highly appreciated.

Thanks

1 ACCEPTED SOLUTION
V-lianl-msft
Community Support
Community Support

Hi @binerdy ,

 

Try to create two columns like below:

count_customer = CALCULATE(COUNT('Table'[date]),ALLEXCEPT('Table','Table'[customerKey]))
groups = SWITCH(TRUE(),
            'Table'[count_customer]>=1&&'Table'[count_customer]<=5,"1-5",
            'Table'[count_customer]>=6&&'Table'[count_customer]<=10,"6-10",
            ">10")

V-lianl-msft_0-1610348659847.png

Sample .pbix

 

Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
V-lianl-msft
Community Support
Community Support

Hi @binerdy ,

 

Try to create two columns like below:

count_customer = CALCULATE(COUNT('Table'[date]),ALLEXCEPT('Table','Table'[customerKey]))
groups = SWITCH(TRUE(),
            'Table'[count_customer]>=1&&'Table'[count_customer]<=5,"1-5",
            'Table'[count_customer]>=6&&'Table'[count_customer]<=10,"6-10",
            ">10")

V-lianl-msft_0-1610348659847.png

Sample .pbix

 

Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

parry2k
Super User
Super User

@binerdy it will work, but not sure why you are getting this error. Can you change Countrows to COUNT ( FactTable[CustomerKey] ) 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

parry2k
Super User
Super User

@binerdy add a new column in customer table, it is similar to ABC analysis

 

Count in Sales Table = 
CALCULATE ( COUNTROWS ( SalesTable ), ALLEXCEPT ( Customer, Customer[CustomerKey] ) )

 

Now in a table visual, use this new column (don't; summarize it since it is a number) and put the sale amount from the sales table, and you will get the result.

 

Check my latest blog post Year-2020, Pandemic, Power BI and Beyond to get a summary of my favourite Power BI feature releases in 2020

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

@parry2kThank you for your response.

I'm getting this error

binerdy_0-1609952046675.png

and if it is corrected ,how will we be calculating the sum of saleAmount against the grouping of customer counts.

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.