3 Replies Latest reply: Apr 4, 2014 3:05 AM by krishnamurthy ramaiah

# Custom sorting bar chart to include "Other" dimension value.

Given a table with the following schema:

DateProductUnits Sold
1/1/2014Hat20
1/1/2014Sweater30
1/2/2014Hat10
1/2/2014Scarf5

I have a bar chart with the following requirements:

Display the Units Sold for the top 6 Products by Date for a given period.

Include an "Other" product to represent values not in the top 6.

Sort the bar segments according to the rank of Units Sold on the last Date of the given period such that the Product with the most sales over the period is assigned to the first (bottom) bar segment, the next highest product gets the next highest bar segment, etc.

So, I create the chart with two dimensions (Date and Product) and an expression of sum([Units Sold]).

I set a Dimensional Limit of Top 6 on Product, and enable "Other".

In the Sort expression I copy the chart expression and add set analysis resulting in sum({<Date={\$(=max(Date))}>}[Units Sold])

This works exactly as I want with the exception that the chart segment assigned to "Other" isn't affected by the Sort expression and always ends up being stuck on the top of each bar.

So, is there a way to modify my Sort expression so that it affects the "Other" segment or do I have to disable the built-in "Other" value and calculate an "Other" value myself and then include my "Other" calculation in my Sort expression? If the solution is to calculate "Other" myself, I'd appreciate any pointers on how to do that given that I've still got the Top 6 dimensional limit in place.

Thanks.

Steven

• ###### Re: Custom sorting bar chart to include "Other" dimension value.

Can you provide some more sample data?

• ###### Re: Custom sorting bar chart to include "Other" dimension value.

perhaps with rank and aggr you can sort "Other"

see attachment

calc dim is

=if(aggr(rank(sum(Units)), Product)<=3,Product, 'Other')

sort order is (d is date)

=sum({\$<d={'\$(=date(max(d)))'}> }Units)

• ###### Re: Custom sorting bar chart to include "Other" dimension value.

Similar requirement, explained in this blog post: Qlikview Bitz and Pieces: Custom Sort in Qlikview