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: 
srinivasa1
Creator II
Creator II

Sum of dynamic variables value in expression

Hi

I need to do Sum of dynamic variables value in expression my code as below.

=sum({$<v_product={'Product_10'},v_product={'Product_11'}>} Product_10)

How i can achive this? i have year 2010 and 2011 if im click on 2010 then ------sum('Product_10') if im selecting 2011 then sum('Product_11')

thx in adavnce

1 Solution

Accepted Solutions
CELAMBARASAN
Partner - Champion
Partner - Champion

Hi,

     If your going with yours then simply use

     Sum($(=vProduct))

Hope it helps

Celambarasan

View solution in original post

9 Replies
CELAMBARASAN
Partner - Champion
Partner - Champion

Hi,

     Use like this on click on 2010 set variable value as Product_10 and on 2011 as Product_11

     Then Use expression as

     =Sum({<ProductFieldName={'$(=v_product)'}>} Sales)

Celambarasan

srinivasa1
Creator II
Creator II
Author

Thx for reply.

in my case i  both variable Product_10 (2010)and as Product_11( 2011) my etl filed also like below

    

if(Year = '2010',ProductQty) as Product_10,

      if(Year = '2011',ProductQty) as Product_11

now i need to do sum based on selecting year.

deepakk
Partner - Specialist III
Partner - Specialist III

hi Srini,

Don't use product_10 or product_11 as field . use the original field ProductQty. This willl be easy.

So when u select year 2010 you will get the ProductQty  for 2010.

The method you have used is making thing complex.

Deepak

v_iyyappan
Specialist
Specialist

Hi,

     Use the expression like as

  if(GetFieldSelections(Year) = vCurrent,Sum({<ProductFieldName={'$(='Product_10)'}>} Sales),

     if(GetFieldSelections(Year) = vPrevious,Sum({<ProductFieldName={'$(='Product_11)'}>} Sales)), 0)

Where

vCurrent  = Max(Year)

vPrevious = Max(Year) -1

Regards,

Iyyappan

srinivasa1
Creator II
Creator II
Author

thx deepak.

CELAMBARASAN
Partner - Champion
Partner - Champion

Hi,

     If your going with yours then simply use

     Sum($(=vProduct))

Hope it helps

Celambarasan

srinivasa1
Creator II
Creator II
Author

Hi Thx Cela

Im looking something like ur way.will it do sum? now im not getting sum for variables vProduct

CELAMBARASAN
Partner - Champion
Partner - Champion

Hi,

     Ya it will do sum if you set variable value as ='Product_10'.Check with it.

Celambarasan

srinivasa1
Creator II
Creator II
Author

Hi Clea.

thx its working....