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
shriramvbi
New Member

How to create a stacked bar containing top 5 sales and others?

Hi All,

I'm new to Power BI. I have a stacked graph like this below,

shriramvbi_0-1652941083737.png

The visual shows the total sales across different countries and the cities acts like stacks. My requirement is to regroup this stack into two categories - Top 5 city sales as one group, and the rest as a separate group.

Example- US consists of cities like NY, LA and many others. I need to group the top 5 cities in the US such as NY, LA and 3 other cities in one group, the other cities that do not fall in the top 5 should be in a separate group named "Others" (Like the below chart). The report should show data for all the countries like this.

shriramvbi_1-1652941537857.png

I have attached the link to the PBIX for your reference. Thanks to you in advance!

PBIX file link - Download PBIX file here 

With regards,

Shriram

 

1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @shriramvbi 

 

You can try the following methods.

Column:

Sales = CALCULATE (Orders[Sales_DAX])
Rank = RANKX('Pseudo Country Table',[Sales])
Category = IF([Rank]<=5,"Top 5 city sales","Other city sales")
Sum sales =
CALCULATE (
    SUM ( 'Pseudo Country Table'[Sales] ),
    FILTER (
        'Pseudo Country Table',
        [Category] = EARLIER ( 'Pseudo Country Table'[Category] )
    )
)

vzhangti_0-1653289474195.pngvzhangti_1-1653289562376.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

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

1 REPLY 1
v-zhangti
Community Support
Community Support

Hi, @shriramvbi 

 

You can try the following methods.

Column:

Sales = CALCULATE (Orders[Sales_DAX])
Rank = RANKX('Pseudo Country Table',[Sales])
Category = IF([Rank]<=5,"Top 5 city sales","Other city sales")
Sum sales =
CALCULATE (
    SUM ( 'Pseudo Country Table'[Sales] ),
    FILTER (
        'Pseudo Country Table',
        [Category] = EARLIER ( 'Pseudo Country Table'[Category] )
    )
)

vzhangti_0-1653289474195.pngvzhangti_1-1653289562376.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.