Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be 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

Reply
Anonymous
Not applicable

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

1 ACCEPTED SOLUTION
v-angzheng-msft
Community Support
Community Support

Hi, @Anonymous 

 

Solution1:

I created a sample with the following data:

vangzhengmsft_0-1630656252421.png

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:

vangzhengmsft_1-1630656318544.png

result:

vangzhengmsft_2-1630656555500.png

 

Edit:

Solution2:

1. Create 2 whatif parameters to control the maximum and minimum values.

 

2. Create a grouping table, which contains three groups, namely <,<>,>.

vangzhengmsft_1-1631792959568.png

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.

vangzhengmsft_2-1631793019251.png

 

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.

View solution in original post

3 REPLIES 3
v-angzheng-msft
Community Support
Community Support

Hi, @Anonymous 

 

Solution1:

I created a sample with the following data:

vangzhengmsft_0-1630656252421.png

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:

vangzhengmsft_1-1630656318544.png

result:

vangzhengmsft_2-1630656555500.png

 

Edit:

Solution2:

1. Create 2 whatif parameters to control the maximum and minimum values.

 

2. Create a grouping table, which contains three groups, namely <,<>,>.

vangzhengmsft_1-1631792959568.png

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.

vangzhengmsft_2-1631793019251.png

 

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.

Fowmy
Super User
Super User

@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




Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Anonymous
Not applicable

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'.

sbnst21_0-1630479965651.png

 

Helpful resources

Announcements
ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.