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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
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
Mark_Little
Luminary
Luminary

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
Author

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.

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

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

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

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