Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Rank with subtotals

Hi All,

I am facing the issue in creating Straight table with Rank. I have products and in front end I am having input box to show ranks dynamically. I am able to achieve the dynamic ranking , but I am not able to achieve below format

Lets say for Top 5 Product I want to achieve below format

Product                  Sales

1                               50

2                               40

3                               30

4                               20

5                               10

Sub Total Top 5       150

Others                      100

Grand Total               250

I tried using value list but it's not working as Top Product is dynamic.

Please suggest it's urgent

1 Solution

Accepted Solutions
Kushal_Chawda

Please see the attached

View solution in original post

15 Replies
Not applicable
Author

Let try with Dimension Limits on straight table.

qlikviewwizard
Master II
Master II

Hi,

Please use this application.

Not applicable
Author

gwassenaarswuehlMayilVahanansunindia‌  Please help

Not applicable
Author

I am not getting sub total for Top 5. This I am already able to achieve

vikasmahajan

PFA  solution

Vikas

Hope this resolve your issue.
If the issue is solved please mark the answer with Accept as Solution & like it.
If you want to go quickly, go alone. If you want to go far, go together.
sunny_talwar

May be not the best way to do it, but gets the result you are looking for:

Capture.PNG

Dimension: =ValueList($(vList))

Where vList

=Concat(DISTINCT {<Product = {"=Rank(Sum(Sales)) <= 5"}>} Chr(39) & Product & Chr(39), ', ') & ', ' &

Chr(39) & 'Subtotal Top5' & Chr(39) & ', ' & Chr(39) & 'Others' & Chr(39)



Expression:

=If(Dimensionality() = 0, Sum(Aggr(Avg(Sales), Product)),

If(ValueList($(vList)) = Only({<Product = {"=Rank(Sum(Sales)) = 1"}>}Product), Sum({<Product = {"=Rank(Sum(Sales)) = 1"}>}Sales),

If(ValueList($(vList)) = Only({<Product = {"=Rank(Sum(Sales)) = 2"}>}Product), Sum({<Product = {"=Rank(Sum(Sales)) = 2"}>}Sales),

If(ValueList($(vList)) = Only({<Product = {"=Rank(Sum(Sales)) = 3"}>}Product), Sum({<Product = {"=Rank(Sum(Sales)) = 3"}>}Sales),

If(ValueList($(vList)) = Only({<Product = {"=Rank(Sum(Sales)) = 4"}>}Product), Sum({<Product = {"=Rank(Sum(Sales)) = 4"}>}Sales),

If(ValueList($(vList)) = Only({<Product = {"=Rank(Sum(Sales)) = 5"}>}Product), Sum({<Product = {"=Rank(Sum(Sales)) = 5"}>}Sales),

If(ValueList($(vList)) = 'Subtotal Top5', Sum({<Product = {"=Rank(Sum(Sales)) <= 5"}>}Sales),

If(ValueList($(vList)) = 'Others', Sum({<Product = {"=Rank(Sum(Sales)) > 5"}>}Sales)))))))))

Not applicable
Author

Thanks for the reply. But I think you have individually created expression using Value list.. In my case I have inputbox for Rank so now it's top 5 , but when user will input 10. it should be top 10.

Hope it is clear now

sunny_talwar

If there is a upper limit to the rank a user can enter, we can still make the above dynamic, but the expression will be huge. Not sure if there is another way to do it, may be somebody else can help you out.

Best,

Sunny

Kushal_Chawda

May be you can try something like below

Create inline Table

Measure:

LOAD * Inline [

Measure

1

2

3 ]

Create straight Table

Dimension:

=Pick(Measure,Product,'Sub Total Top $(vTop)','Others')   where vTop is your variable

Expression:

=Pick(Measure,

sum({<Product={"=rank(sum(Sales),4)<=$(vTop)"}>}Sales),

sum({<Product={"=rank(sum(Sales),4)<=$(vTop)"}>}Sales),

sum({<Product={"=rank(sum(Sales),4)>$(vTop)"}>}Sales))

Also see some settings in Sort Tab of Chart and Text format of Dimension.

Hope it helps

See the attached.