cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

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
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors