Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
udaya_kumar
Specialist
Specialist

Calculating Share giving problem

Hi,

i have calculated share using the expression,

=sum(Volume) / sum(total<MONTH_NAME,MARKET_NAME> Volume)

the table shows the share for all the products in the market.

when i select some products, then share calculated among those selected products for a given month and given market.

i dont want it to calculate share among those products, i want share to be calculated for all the products.

ex;

Product Name
Share
Hum60%
Enb20%
Ste-
Sim20%

so if i unselect Enb from the product list, the share should show like this

Hum-60%

Sim-20%

Ste- -,

It should not show like this

Hum-70%

Sim-30%

Ste--

so how to change the expression, so that i will get like this

Hum-60%

Sim-20%

Ste- -,

1 Solution

Accepted Solutions
udaya_kumar
Specialist
Specialist
Author

hi,

i used this expression

if(MetricName='NRx Share',

(Sum(Volume)/

aggr(NODISTINCT Sum({<PRODUCT_NAME=>} Volume),MONTH_NAME)))

it works fine

View solution in original post

3 Replies
Not applicable

I think the expression should look something like this: sum(volume/sum(total {<product=>} volume). See example below. You should be able to add in the month if need be. I believe this logic is covered in "set modifiers" in the reference manual. You can set the value of product to be a specific value or to be all values, regardless of selections. Examples would be: sum(volume/sum(total {<product={'a'}>} volume) or the one above.
jagan
Luminary Alumni
Luminary Alumni

Hi,

Can you attach sample file that you are working. 

Try calculating the Total and store it in variable and use this variable in expression like this.

your variable should be

vTotalValue = Sum({1} Volume)

So, now total is calculated, this value is used in expression like this

=sum(Volume)/vTotalValue

Now you will get the result as you expected.

Hope this helps you.

Regards,

Jagan.

udaya_kumar
Specialist
Specialist
Author

hi,

i used this expression

if(MetricName='NRx Share',

(Sum(Volume)/

aggr(NODISTINCT Sum({<PRODUCT_NAME=>} Volume),MONTH_NAME)))

it works fine