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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Recalculate field in script

At the end of my script I want to recalculate the [Exp hrs].

In one LOAD-statement I'm adding the fields [%Date], [Actual Hours], [Exp hrs] and [Calculation Method] to [MyTable]

I'm using a JOIN to add the field [Target Prod]

Now depending on the Calculation Method the Expected hours need to be recalculated.

My join doesn't recalculate all the records in [MyTable]

// use calculation method to recalculate [Exp hrs]

LEFT JOIN ([MyTable])

LOAD If ([Calculation Method]=2,

      IF ([Actual Hours]>0, [Target Prod],

      0),

      [Exp hrs])

      as [Exp Hours]

RESIDENT MyTable;

Drop Fields [Exp hrs];

Can anyone tell me how I'm supposed to recalculate all records?

Labels (1)
1 Solution

Accepted Solutions
Clever_Anjos
Support
Support

Why JOIN?

You can

NewTable:

LOAD

  *,

If ([Calculation Method]=2,

      IF ([Actual Hours]>0, [Target Prod],

      0),

      [Exp hrs])

      as [Exp Hours]

resident MyTable;

Drop table MyTable

View solution in original post

3 Replies
rbecher
Partner - Master III
Partner - Master III

Hi Erik,

I think you'll need at least one identifying column to match the row for the join:

LEFT JOIN (MyTable)

LOAD ID, <Expression> as Exp

Resident MyTable;

- Ralf

Data & AI Engineer at Orionbelt.ai - a GenAI Semantic Layer Venture, Inventor of Astrato Engine
Clever_Anjos
Support
Support

Why JOIN?

You can

NewTable:

LOAD

  *,

If ([Calculation Method]=2,

      IF ([Actual Hours]>0, [Target Prod],

      0),

      [Exp hrs])

      as [Exp Hours]

resident MyTable;

Drop table MyTable

rbecher
Partner - Master III
Partner - Master III

Why Join: if this is a large fact table it could have serious memory implications..

Data & AI Engineer at Orionbelt.ai - a GenAI Semantic Layer Venture, Inventor of Astrato Engine