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: 
kolov007
Contributor III
Contributor III

Maximum value of strings

Hello.

In the column "Share Product 1", I calculate the share of sales of product 1 from sales total for each filial:

Sum ({<Product = {'Product 1'}>}Amount)/Sum (Amount)

Screenshot_1.png

I need to calculate the maximum share of product 1 among all the filials and the deviation from this share.

Help me please.

1 Solution

Accepted Solutions
tamilarasu
Champion
Champion

Hi Evgen,

Max( Total aggr(Sum ({<Product = {'Product 1'}>}Amount)/Sum (Amount), Filial))

View solution in original post

3 Replies
tamilarasu
Champion
Champion

Hi Evgen,

Max( Total aggr(Sum ({<Product = {'Product 1'}>}Amount)/Sum (Amount), Filial))

stigchel
Partner - Master
Partner - Master

For max share

=max(TOTAL aggr(Sum ({<Product = {'Product 1'}>} Amount)/Sum (Amount), Filial))

Difference

=[Share Product 1]-[Max Share]

ScrTest6.png

petter
Partner - Champion III
Partner - Champion III

More for the sake of demonstrating Qlik's flexibility in how to calculate various things I present these two alternative expressions that don't use Aggr() to calculate Max Share:

Sum (TOTAL {<Product={'Product 1'},Filial={"=Rank(Sum({<Product={'Product 1'}>} Amount)/Sum(Amount))=1"}>} Amount) / Sum(TOTAL {<Filial={"=Rank(Sum({<Product={'Product 1'}>} Amount)/Sum(Amount))=1"}>} Amount)

or

RangeMax(Top( [Share Product 1],1,NoOfRows()))

Will both calculate the same as:

Max(TOTAL Aggr(Sum ({<Product = {'Product 1'}>} Amount)/Sum (Amount), Filial))