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

Distinct Count by Sum of Column

Hello! I'm looking to count distinct sales rep by summarized commission values. I have page slicers such as date and plan so I'm trying to keep this dynamic. Anytime I try to get a count of sales rep by commission it rolls into one large sum or breaks out by customerID instead of Sales Rep. 

Example Table: 

sarhutson_0-1663786532902.png
This is what I keep getting in PowerBI: 

sarhutson_2-1663786621588.png

 

This is my desired result: 

sarhutson_1-1663786554437.png

The end goal will be to get a count of sales rep in buckets of "Less than 300","Less than 500","Less than 700", etc. this is a simplified example 

 

Any suggestions? 

2 ACCEPTED SOLUTIONS
AnthonyJoseph
Resolver III
Resolver III

Hi @sarhutson 
In my view, to achieve this we need to create a calculated column (grouped by name) and a measure.

I have mocked up the table name to be "Commission data" and sales rep to be "Name" and below are the codes.

 

1) Calculated column

 

grouped by name = 
var _name = 'Commission data'[Name]
var _value =  SUMX(FILTER('Commission data','Commission data'[Name] = _name),'Commission data'[Commission])
return 
SWITCH(TRUE(),
_value <=300, "Less than or equal to 300",
_value <=500, "Less than or equal to 500",
_value <=700,"Less than or equal to 700")

 

 

2)Measure will be to get the uniqe sales reps: 

 

unique sales reps = DISTINCTCOUNT('Commission data'[Name])

 

 

Then, I added these two in a table to get the desired output:

 

AnthonyJoseph_0-1663793738192.png

 

Hope this helps!

 

Thanks

AnthonyJoseph

View solution in original post

parry2k
Super User
Super User

@sarhutson you are looking for dynamic segmentation, check this blog post  Dynamic segmentation – DAX Patterns

 

 

Follow us on LinkedIn and YouTube.gif to our YouTube channel

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make effort 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.

View solution in original post

3 REPLIES 3
parry2k
Super User
Super User

@sarhutson you are looking for dynamic segmentation, check this blog post  Dynamic segmentation – DAX Patterns

 

 

Follow us on LinkedIn and YouTube.gif to our YouTube channel

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make effort 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.

AnthonyJoseph
Resolver III
Resolver III

Hi @sarhutson 
In my view, to achieve this we need to create a calculated column (grouped by name) and a measure.

I have mocked up the table name to be "Commission data" and sales rep to be "Name" and below are the codes.

 

1) Calculated column

 

grouped by name = 
var _name = 'Commission data'[Name]
var _value =  SUMX(FILTER('Commission data','Commission data'[Name] = _name),'Commission data'[Commission])
return 
SWITCH(TRUE(),
_value <=300, "Less than or equal to 300",
_value <=500, "Less than or equal to 500",
_value <=700,"Less than or equal to 700")

 

 

2)Measure will be to get the uniqe sales reps: 

 

unique sales reps = DISTINCTCOUNT('Commission data'[Name])

 

 

Then, I added these two in a table to get the desired output:

 

AnthonyJoseph_0-1663793738192.png

 

Hope this helps!

 

Thanks

AnthonyJoseph

Thank you @AnthonyJoseph ! This is very helpful!! Is there anyway to calculate the groupings in a measure so they will flex off of the date and plan columns so its dynamic? For example if I select the remote plan all 5 associate would then fall under "Less than or equal to $300"?

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.