- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dynamic Grouping of Data in Visual Columns using Age(Values on X Axis) Slicer
Hello All Colleagues,
I want to group data(should come on Y Axis) in columns based on Age division(Age should come on X Axis) such that I need to select Maximum and Minimum Age based on What-if slicer values selection.
What approach do I need to follow??
Can someone give a quick solution to this. It will be much helpful
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, @Anonymous
Solution1:
I created a sample with the following data:
Create 2 measures to determine the maximum and minimum values. It acts as a slicer
_min = 60
_max = 120
Create another measure to group ages.
Group =
var _age=MAX('Table'[Age])
var _if=
SWITCH(TRUE(),
_age<[_min],"<"&[_min],
_age>[_max],">"&[_max],
[_min]&"~"&[_max])
return IF(ISFILTERED('Table'[Name]),_if)
Then, create a calculated table to get the grouped fields.
T = ADDCOLUMNS('Table',"Group",[Group])
Finally, create a measure to count users.
Model:
result:
Edit:
Solution2:
1. Create 2 whatif parameters to control the maximum and minimum values.
2. Create a grouping table, which contains three groups, namely <,<>,>.
3. Then create a measure to calculate the count of names in the group.
R_Count =
var _swith=
SWITCH(
MAX('_Range'[Range]),
"<",CALCULATE(COUNT('Table'[Name]),FILTER(ALL('Table'),'Table'[Age]<[_MINage Value])),
">",CALCULATE(COUNT('Table'[Name]),FILTER(ALL('Table'),'Table'[Age]>[_MAXage Value])),
CALCULATE(COUNT('Table'[Name]),FILTER(ALL('Table'),'Table'[Age]<=[_MAXage Value]&&'Table'[Age]>=[_MINage Value])))
return IF(HASONEVALUE('_Range'[Range]),_swith,COUNT('Table'[Name]))
Finally, a bar graph is created with the groups and measures of the grouping table.
Please refer to the attachment below for details. Hope this helps.
Best Regards,
Community Support Team _ Zeon Zheng
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, @Anonymous
Solution1:
I created a sample with the following data:
Create 2 measures to determine the maximum and minimum values. It acts as a slicer
_min = 60
_max = 120
Create another measure to group ages.
Group =
var _age=MAX('Table'[Age])
var _if=
SWITCH(TRUE(),
_age<[_min],"<"&[_min],
_age>[_max],">"&[_max],
[_min]&"~"&[_max])
return IF(ISFILTERED('Table'[Name]),_if)
Then, create a calculated table to get the grouped fields.
T = ADDCOLUMNS('Table',"Group",[Group])
Finally, create a measure to count users.
Model:
result:
Edit:
Solution2:
1. Create 2 whatif parameters to control the maximum and minimum values.
2. Create a grouping table, which contains three groups, namely <,<>,>.
3. Then create a measure to calculate the count of names in the group.
R_Count =
var _swith=
SWITCH(
MAX('_Range'[Range]),
"<",CALCULATE(COUNT('Table'[Name]),FILTER(ALL('Table'),'Table'[Age]<[_MINage Value])),
">",CALCULATE(COUNT('Table'[Name]),FILTER(ALL('Table'),'Table'[Age]>[_MAXage Value])),
CALCULATE(COUNT('Table'[Name]),FILTER(ALL('Table'),'Table'[Age]<=[_MAXage Value]&&'Table'[Age]>=[_MINage Value])))
return IF(HASONEVALUE('_Range'[Range]),_swith,COUNT('Table'[Name]))
Finally, a bar graph is created with the groups and measures of the grouping table.
Please refer to the attachment below for details. Hope this helps.
Best Regards,
Community Support Team _ Zeon Zheng
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@Anonymous
Not clear enough but as I read your question, you can add Parameter on the report and modify your measure to within the Min and Max values selected in the Paramter.
You can find many articles and videos on google
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It is like the screenshot below, such that when I select limit1 as 60 and limit2 as 120, so the bar graph will show like 1st bar should be '<60', 2nd bar should be between '60 to 120', 3rd bar should be 'more than 120'.
Helpful resources
Join us at the Microsoft Fabric Community Conference
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Power BI Monthly Update - January 2025
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
Subject | Author | Posted | |
---|---|---|---|
Anonymous
| 06-28-2024 12:43 AM | ||
06-18-2024 09:55 AM | |||
01-09-2024 07:56 AM | |||
07-12-2024 06:18 AM | |||
07-16-2024 02:55 AM |
User | Count |
---|---|
98 | |
69 | |
46 | |
39 | |
33 |
User | Count |
---|---|
157 | |
101 | |
60 | |
42 | |
40 |