Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

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

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

3 Replies

  • 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




    • Anonymous's avatar
      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'.

       

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