Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
Not applicable

How to get the reduction field value into script

I am using loop reduce by Country field .

I have 2 values in Country field US, UK so job is creating 2 QVWs from main qvw.

But in the qlikview script we have defined variable

LET LOC = if(Country='US',1,2);

but when ever i am running the job , it is creating two Qvws but LOC is always assigning 2.

Please let me know how to Pass the Country Field value into script from reduction field.

4 Replies
mark6505
Valued Contributor III

Re: How to get the reduction field value into script

HI,

Not sure how you an do this in script.

Can you not just add the expression to a variable in the front end?

Mark

Not applicable

Re: How to get the reduction field value into script

as i have one qvw and i am reducing it on the basis of Country field.

I can not do any thing in new qvws .

but i need to assign value to variable on the basis of country.

LET LOC = if(Country='US',1,2);

But it is always assigning LOC=2 as Country = US is not executing as value of Country is passing by job


Please let me know how to pass the reduction field value to variable in to script.

Re: How to get the reduction field value into script

Hi,

What is happening here is you can not use the If statement like this.

Try below Script.

MaxString:

Load Maxstring(Country) as MaxCountry

From XYZ;

Let vMax = Peek('MaxCountry',0,'MaxString');

Let LOC = if($(vMax) = 'US',1,2);

Regards,

Kaushik Solanki

Re: How to get the reduction field value into script

Reduction is done after script is run. Or to say it another way, script is run before reduction. So you will always have the full set of data -- both countries -- when the script runs.

-Rob

http://masterssummit.com

http://qlikviewcookbook.com

Community Browser