Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
Hi there,
I was hoping someone may be able to help with a dynamic segmentation query in Power BI.
I have an activities table (SQLActivities) which contains columns called activityID and callerID. The principle of the table is that a single callerID can have multiple activityID. I'm trying to create two pie charts to show:
1) Callers grouped into buckets based on number of activities per caller, and
2) Activities grouped by the same buckets for each caller. For the second pie chart I am essentially trying to show how many activities in each caller bucket -i.e. if two callers had 11 or more activities, how many activities were actually in that bucket.
I have created a table to specificy the values of the buckets - they are 1, 2, 3 - 5, 6 - 10, and 11 or more. I created the table as follows:
Solved! Go to Solution.
Hi @Cogden ,
According to your description, here are my steps you can follow as a solution.
(1) This is my test data.
(2) We can create measures.
Bucket =
var _A= COUNTROWS(FILTER(ALLSELECTED('SQLActivities'),'SQLActivities'[callerID]=MAX('SQLActivities'[callerID])))
var _bucket=SWITCH (
TRUE (),
_A = 1, "1",
_A= 2, "2",
_A <= 5, "3 - 5",
_A <= 10, "6 - 10",
_A > 10, "11 or more"
)
return _bucket
Count = COUNTROWS(FILTER('SQLActivities',[Bucket] = MAX('ActivitySegments'[Bucket])))
(3) Then the result is as follows.
If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.
Best Regards,
Neeko Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Cogden ,
According to your description, here are my steps you can follow as a solution.
(1) This is my test data.
(2) We can create measures.
Bucket =
var _A= COUNTROWS(FILTER(ALLSELECTED('SQLActivities'),'SQLActivities'[callerID]=MAX('SQLActivities'[callerID])))
var _bucket=SWITCH (
TRUE (),
_A = 1, "1",
_A= 2, "2",
_A <= 5, "3 - 5",
_A <= 10, "6 - 10",
_A > 10, "11 or more"
)
return _bucket
Count = COUNTROWS(FILTER('SQLActivities',[Bucket] = MAX('ActivitySegments'[Bucket])))
(3) Then the result is as follows.
If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.
Best Regards,
Neeko Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
16 | |
13 | |
12 | |
11 | |
11 |
User | Count |
---|---|
19 | |
14 | |
14 | |
11 | |
9 |