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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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
July 2024 Power BI Update

Power BI Monthly Update - July 2024

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

July Newsletter

Fabric Community Update - July 2024

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