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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Dynamic Grouping based on Rank

Hi Everyone,

 

I want to create group on top of States based up on count of coustomers.

where the rank of customers greater than 5 then it has to group together as 'Others' , rest diaply as it is.

The grouping should be dynamic based on Customers count.

 

Please find example below:

I have data like below Screen shot 1

Screen Shot1.PNG

 

And I have to create a group as below screen shot2 

Screen Shot2.PNG

Need your help,  Thanks,

 

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

Hi @Anonymous,

 

You can try to use below calculated column formula to achieve your requirement.

 

Logic:

1. Calculate current rank.

2, Add if statement to replace column name to other when rank greater than 5.

 

 

Categroy =
VAR summary =
    SUMMARIZE ( 'Table', [Type], "Count", COUNT ( [Index] ) )
VAR _rank =
    MAXX (
        FILTER (
            ADDCOLUMNS (
                summary,
                "Rank", RANKX ( summary, [Count], MAX ( [Count] ), DESC, DENSE )
            ),
            [Type] = EARLIER ( 'Table'[Type] )
        ),
        [Rank]
    )
RETURN
    IF ( _rank <= 5, [Type], "Other" )

11.PNG

 

 

Regards,
Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

3 REPLIES 3
v-shex-msft
Community Support
Community Support

Hi @Anonymous,

 

You can try to use below calculated column formula to achieve your requirement.

 

Logic:

1. Calculate current rank.

2, Add if statement to replace column name to other when rank greater than 5.

 

 

Categroy =
VAR summary =
    SUMMARIZE ( 'Table', [Type], "Count", COUNT ( [Index] ) )
VAR _rank =
    MAXX (
        FILTER (
            ADDCOLUMNS (
                summary,
                "Rank", RANKX ( summary, [Count], MAX ( [Count] ), DESC, DENSE )
            ),
            [Type] = EARLIER ( 'Table'[Type] )
        ),
        [Rank]
    )
RETURN
    IF ( _rank <= 5, [Type], "Other" )

11.PNG

 

 

Regards,
Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Hi Xiaoxin,

 

I have a similar problem and your solution looks pretty neat.

 

Would you help me adapt your script to group [Type] by the share %?

 

In this example, if COUNT( [Index] ) as % of Total < 4% then "Other".

 

Many thanks!

 

Fiorenzo

Anonymous
Not applicable

It is working perfect as expected. Thanks much Xiaoxin Sheng...!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.