March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
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.
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.
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.
@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
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'.
User | Count |
---|---|
120 | |
78 | |
58 | |
52 | |
46 |
User | Count |
---|---|
170 | |
117 | |
63 | |
58 | |
51 |