Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Passing a variable to an expression

Hi there,

I'm having a problem returning a value for my expression below

sum({<TrnMonth={$('vTrnMonthSelected')}>}NetSalesValue)

where TrnMonth is the selection the user makes via a List Box

and vTrnMonthSelected is a variable with the below formula

GetFieldSelections(TrnMonth)

and NetSalesValue is the summed value I want returned.

All I get back is 0.

When I use just $(vTrnMonthSelected) it returns the selections but whenever I run the main sum line, I cannot seem to get it to work.

Any help would be brilliant

Thanks

6 Replies
alexandros17
Partner - Champion III
Partner - Champion III

Use

={$(vTrnMonthSelected)}>} without ' char ... or ={'$(vTrnMonthSelected)'}>}

Hope it helps

Not applicable
Author

Unfortunately still not working with :

sum({<TrnMonth={'$(vTrnMonthSelected)'}>}NetSalesValue)

Yeah I know I could just use the sum(NetSalesValues), I wanted to use the formula though to add some logic and this was the first step in getting the completed formula complete, but alas it still doesn't work

Not applicable
Author

Nope, neither works unfortunately

er_mohit
Master II
Master II

try this without using variable,

sum({<TrnMonth={"$(=TrnMonth)"}>NetSalesValue)

and for variable create like this:-

vTrnMonthSelected

=(SubField(GetCurrentSelections(),':',-1))

hii sry for late response, try this

THEN,

sum(if(TrnMonth=vTrnMonthSelected,NetSalesValue))

HOPE it helps

Not applicable
Author

Your first expression works, I then add the variable like you show,

But the last expression still doesn't work

danielrozental
Master II
Master II

Change your variable from "GetFieldSelections(TrnMonth)" to "=GetFieldSelections(TrnMonth)"