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: 
lukas_sokol
Contributor II
Contributor II

using variable in expresion

Hi,

I have the following problem

I have variable vUserCompanyCode with store  company  codes (loaded from excel) for specifed user

I have sample expresion below ( working)

sum( if( WildMatch(CompanyCode, 10,20,25,30) , NetSales))

but when i use variable ( the result is emty), variable have the same value (10,20,25,30)

sum( if( WildMatch(CompanyCode,$(vUserCompanyCode)) , NetSales))

Regards

Łukasz

1 Solution

Accepted Solutions
tamilarasu
Champion
Champion

No. The vUserComnayCode variable looks fine. You need to change the expression as sum( {<CompanyCode={$(=vUserCompanyCode)}>} NetSales).. Since you are using formula in your vUserCompanyCode. If the above one not work, then try with '$(vUserCompanyCode)'.. Let me know..

View solution in original post

15 Replies
Not applicable

why dont you use set analysis instead to narrow down the Company codes.

sum(    {<CompanyCode={$(=vUserCompanyCode)}>} NetSales)

lukas_sokol
Contributor II
Contributor II
Author

I also try use set analysis as you write.

Unfortunately, it not  helps

Not applicable

what is the exacts out put of the variable vUserCompanyCode?

it should work if it is- 10,20,25,30

Sample qvw would help too

tamilarasu
Champion
Champion

Hi Lukasz,

Change the variable vUseCompanyCode values Format like below,

'10', '20', '25', '30'

Expression as

sum( if( WildMatch(CompanyCode,$(vUserCompanyCode)) , NetSales))

lukas_sokol
Contributor II
Contributor II
Author

Hi,

I did a test, and if I directly enter values ('10', '20', '25', '30') to vUserCompanyCode variable then all options work( with set analysis, wildmatch,match)

However, In this variable, I use the expression

FieldValue ('available Company' Field Index ('user', FieldValue ('user', fieldIndex ('user', $ (vUser)))))

where vUser is  trim(rtrim(subfield(osuser(),'\',2)))

I check then what value store variable and I get '10', '20', '25', '30'.

Maybe text format is wrong?

Gabriel
Partner - Specialist III
Partner - Specialist III

Hi,

Try this

Sum({<CompanyCode={'$(vUserCompanyCode)'}>} NetSales)

lukas_sokol
Contributor II
Contributor II
Author

Unfortunately, it did not help.

I noticed one more thing.

If I load to this variable only one company code, then everything works, if I load more than one Unfortunately not.

Anonymous
Not applicable

Simply write in your variable as =10,20,25,30

Then write an expression like below;

Sum({<CompanyCode ={$(vUserCompanyCode)}>}Net Sales)

Anonymous
Not applicable

Dear Lukasz,

I believe your question has been answered. kindly mark the thread as answered, so that other members can refer to this post.