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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
upaliwije
Creator II
Creator II

variable

Hi Friends

I have created a variable and working fine when applied to a expression as follows

=($(vProfit))

but when I modify the expression like below it does not work.Will you please highlight   the error in expression please

=sum({$<YEAR = {"$(=Only([YEAR]))"},T_YEAR = {"$(=Only([YEAR]))"}>} $(vProfit))

12 Replies
MK_QSL
MVP
MVP

Can you provide some sample data for this ?

upaliwije
Creator II
Creator II
Author

It is difficult to upload the data it is big file. Can you by a look of expression say whether it is coded right

jpenuliar
Partner - Specialist III
Partner - Specialist III

What is the Statement for vProfit variable?

upaliwije
Creator II
Creator II
Author

iT IS LIKE THIS

sum( {<NOTE = {'100'}>}[AMOUNT] )*-1

-sum( {<NOTE = {'101','102','103'}>}[AMOUNT] )

-sum( {<NOTE = {'105','107','108'}>}[AMOUNT] )

-sum( {<NOTE = {'130','131','132','133','134','137','138','139','140'}>}[AMOUNT] )

-sum( {<NOTE = {'120','121','123'}>}[AMOUNT] )

-sum( {<GROUP_CODE = {'MA','MB','MC','MD','ME'}>}[AMOUNT] )

+sum( {<NOTE = {'150','151','160','161'}>}[AMOUNT] )*-1

trdandamudi
Master II
Master II

Try the below code:

=sum({$<YEAR = {"$(=Only([YEAR]))"},T_YEAR = {"$(=Only([YEAR]))"}>} (=$(vProfit)))

upaliwije
Creator II
Creator II
Author

That is also not working

jpenuliar
Partner - Specialist III
Partner - Specialist III

is it correct to assume that :

vProfit = " Sum( {<NOTE = {'100'}>}[AMOUNT] )*-1 sum( {<NOTE = {'101','102','103'}>}[AMOUNT] )

sum( {<NOTE = {'105','107','108'}>}[AMOUNT] )

-sum( {<NOTE = {'130','131','132','133','134','137','138','139','140'}>}[AMOUNT] )

-sum( {<NOTE = {'120','121','123'}>}[AMOUNT] )

-sum( {<GROUP_CODE = {'MA','MB','MC','MD','ME'}>}[AMOUNT] )

+sum( {<NOTE = {'150','151','160','161'}>}[AMOUNT] )*-1"

and you are calling vProfit in a Set Analysis..

upaliwije
Creator II
Creator II
Author

Yes It is correct

luciancotea
Specialist
Specialist

The sum( sum() + sum()..) combination is not a valid one. You need to use aggr():

sum( aggr( sum(), ...) )

And using Set Analysis to filter data is bad practice.