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
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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.