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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
VayneDaryl
Frequent Visitor

How to group categories below the desired percentage of a measure

Hello Everyone Good Day, I am new to Power Bi and Im working on a certain request on a project. I hope that somebody could help or somehow suggest some solutions or possible work around.

Given the visual below, I have to group all Departments with percentage below 4% as Others (all those in the red mark). I also have a Month and Year Filter so these values are dynamically changing depends on the filter. 

VayneDaryl_0-1696166445784.png

Thanks in advance guys.

Regards.

1 ACCEPTED SOLUTION

Hi @VayneDaryl,

AFAIK, current power bi desktop does not support to create dynamic calculate column or table based on filter effects.
If these percentage values are dynamic change based on filter effect, I'd like to suggest you create a new table with all category type values and "other".
After these steps, you can use this new table field as category of the pie chart and write a measure formula with variable and summarize function to summary raw table records based on category.
Then you can check if the current category is included in the list of category values that match condition and return correspond results, not matched records will be replaced to return blank and power bi will auto hide from the chart.(for 'other' group, it will summary 'less than 4% records’)

formula =
VAR summary =
    SUMMARIZE ( ALLSELECTED ( Table1 ), [Category], "Percent", 'percent formula' )
VAR topList =
    SELECTCOLUMNS ( FILTER ( summary, [Percent] > 0.04 ), "Category", [Category] )
VAR currCategory =
    SELECTEDVALUE ( newTable[Category] )
RETURN
    IF (
        currCategory IN topList,
        MAXX ( FILTER ( summary, [Category] = currCategory ), [Percent] ),
        IF (
            currCategory = "Other",
            SUMX ( FILTER ( summary, [Percent] < 0.04 ), [Percent] )
        )
    )

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

4 REPLIES 4
VayneDaryl
Frequent Visitor

Hello Xiaoxin @v-shex-msft,

Thank you so much for your feedback, I really appreciate it. But the case is that calculated columns are not responsive to slicers. I have a month and year slicer so values are dynamically changing.

Regards,

Vayne

Hi @VayneDaryl,

AFAIK, current power bi desktop does not support to create dynamic calculate column or table based on filter effects.
If these percentage values are dynamic change based on filter effect, I'd like to suggest you create a new table with all category type values and "other".
After these steps, you can use this new table field as category of the pie chart and write a measure formula with variable and summarize function to summary raw table records based on category.
Then you can check if the current category is included in the list of category values that match condition and return correspond results, not matched records will be replaced to return blank and power bi will auto hide from the chart.(for 'other' group, it will summary 'less than 4% records’)

formula =
VAR summary =
    SUMMARIZE ( ALLSELECTED ( Table1 ), [Category], "Percent", 'percent formula' )
VAR topList =
    SELECTCOLUMNS ( FILTER ( summary, [Percent] > 0.04 ), "Category", [Category] )
VAR currCategory =
    SELECTEDVALUE ( newTable[Category] )
RETURN
    IF (
        currCategory IN topList,
        MAXX ( FILTER ( summary, [Category] = currCategory ), [Percent] ),
        IF (
            currCategory = "Other",
            SUMX ( FILTER ( summary, [Percent] < 0.04 ), [Percent] )
        )
    )

Regards,

Xiaoxin Sheng

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

Hello @v-shex-msft

Thank you so much for the help, I've been looking for some solutions a couple of days now and this works like a magic 😉 Amazing 😉 
Have a great day.
Regards,
Vayne
 

v-shex-msft
Community Support
Community Support

HI @VayneDaryl,

I'd like to suggest you add a calculated column to your table with if statement to check the current percentage and return the category value or "other" to regroup records, then you can use this to replace raw category fields to display new category on you chart.

Regards,

Xiaoxin Sheng

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

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Power BI Header Change

Power BI Header Update

Read about the exciting updates for the Power BI forum.

Top Solution Authors