Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How do I set a Variable to a Field?

Let iJobLab = [Inventory Job Code];
Sum (
{$<
[Cost Job Code]=${iJobLab}>},

[JobStep Labour Value Estimated])

[Inventory Job Code] is a dimension in my chart.  The [Inventory Job Code] is the same as the [Cost Job Code] only in different tables

What I am trying to do is set the [Cost Job Code] equal to the [Inventory Job Code] so I can pull data for different tables.  I want the end result to look like:

   

InvHistory Transaction DateInventory Item CodeInventory Job CodeShipment COGSLet iJobLab
01/04/201612345209092-21,472.5210,000
01/05/20166789209093-20,000.00 5000

How do I make this happen within the expression?

Thank you

5 Replies
amayuresh
Creator III
Creator III

Firstly variable only hold single value at a time, not set of values.


[Cost Job Code] and [Inventory Job Code] is present in separate table or in same table ?

if both field have same values then you can use directly [Cost Job Code] or [Inventory Job Code] as dimension in your chart / table.

Gysbert_Wassenaar

1. associating tables is done in the script by giving the fields that should link the table the same name

2. you can't use set analysis in the script

3. the = inside 'Sum ( {$<[Cost Job Code]=${iJobLab}>} [JobStep Labour Value Estimated])' is a 'comparison' =, not an 'assignment' =.

4. I have no idea what you're trying to do. Please post a small qlikview document that explains things.


talk is cheap, supply exceeds demand
Hatus
Partner - Creator II
Partner - Creator II

Hi

It is possible to sign one single value to the variable. For this matter I would use the peek() function in the script to take a specific value to work with.

Otherwise you can try to access the dimension value if you write a "if condition" for your sum:

sum(

    if([Cost Job Code] = [Inventory Job Code], [JobStep Labour Value Estimated]

     )

settu_periasamy
Master III
Master III

Hi,

Let iJobLab = [Inventory Job Code]; => This will not assign your value to the Variable. It should be within single Quote.

it should be like


LET iJobLab = '[Inventory Job Code]';


And we can't compare the value inside set analysis. see here.. set_analysis_intra-record.qvw


So, your expression may be like this..

Sum (if([Cost Job Code]=$(iJobLab),[JobStep Labour Value Estimated]))


Kushal_Chawda

You casn try the apply map function to create the flag for matching the code


InventoryCode:

mapping Load Key,

           InventoryCode

FROM Table1;

here Key is link between the table in which Inventory Code and Job code is available

Table:

Load * ,

           if(not isnull(applymap('Map',Key,null()),1,0) as CodeMatchFlag

FROM Table2;

Now you can write the expression

=sum({<CodeMatchFlag={1}>}[JobStep Labour Value Estimated]))