Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Preceding Load Error

Hi,

I seem to be getting an error when creating calculations using a preceding load statement. Below is an example of my code:

Facts:

LOAD *,


     Budget_Parts - Actual_Parts as Total


     ;

LOAD

     CSC#,

     CSC,

     Parts as  Budget_Parts,

     Tires,

     Tools

     'Budget' as Source

FROM [Data\Budget.xlsx];

Concatenate(Facts)

LOAD

     CSC#,

     CSC,

     Parts as Actual_Parts,

     Tires,

     Tools,

     Physical_Damages,

'     Supplies

     'Actuals' as Source

     'Budget' as Source

FROM [Data\Budget.xlsx];

I  obtain a 'Field Not Found' error, where it cannot find 'Actual_Parts'.

What are the workarounds and solutions for this?

Many thanks all

Sabah

9 Replies
ali_hijazi
Partner - Master II
Partner - Master II

the first Load is reading from where?

did you put a from or resident?

I can walk on water when it freezes
Not applicable
Author

Hey,

The first load i.e.

LOAD *,


     Budget_Parts - Actual_Parts as Total


     ;


this is reading from the loaded Facts table which I am first loading


I have tried doing a RESIDENT load, but the value comes out as NULL

sushil353
Master II
Master II

Hi,

You can't use same name for two fields in single table.

'Actuals' as Source,

'Budget' as Source

HTh

sushil

Peter_Cammaert
Partner - Champion III
Partner - Champion III

Various things are unconventional about this piece of code.

  • Indeed, the Preceding Load has no field Actual_Parts, because that one is only created in the 3rd LOAd that doesn't belong to the first two. It's a different table called Facts.
  • In the third LOAD, you cannot create a field called Source twice.
  • There is no condition connected to the last two loads. That means that you are loading your parts twice in exactly the same order and number, once as Budget and once as Actual. Pretty weird.

To fix the problem in your post title: remove the first (Preceding) LOAD and put this behind the two remaining LOADS:

Facts2:

NOCONCATENATE

LOAD *, Budget_Parts - Actual_Parts as Total

RESIDENT Facts;

But even while this may seem to work, it doesn't make sense because every Budget_Part field has an Actual_Parts field equal to NULL, and vice versa.

Rethink your logic.

Not applicable
Author

Sushil,

even with the Source Field commented out, it still raises the following error:

error1.JPG.jpg

Peter_Cammaert
Partner - Champion III
Partner - Champion III

Your posted script is different from the one in this error message. We are talking about different things here. How exactly do you want us to help you?

Not applicable
Author

Hi,

Try this

Facts:

LOAD

     CSC#,

     CSC,

     Parts as  Budget_Parts,

     Tires,

     Tools

     'Budget' as Source

FROM [Data\Budget.xlsx];

Concatenate(Facts)

LOAD

     CSC#,

     CSC,

     Parts as Actual_Parts,

     Tires,

     Tools,

     Physical_Damages,

'     Supplies

     'Actuals' as Source

     'Budget' as Source

FROM [Data\Budget.xlsx];

Load *,

      [Budget_Parts]-[Actual-Parts] as Total

resident Facts;

djsampat
Creator II
Creator II

I agree with rakesh1108 that you should change the order and load the Actuals and Budgets and then combine them.

If this helped you, please mark as Helpful. If it solves your issue, please mark as Answer

Regards

Dhruv

jagan
Luminary Alumni
Luminary Alumni

Hi,

Try like this

Temp: 

LOAD

     CSC#,

     CSC,

     Parts as  Budget_Parts,

     Tires,

     Tools,

     'Budget' as Source

FROM [Data\Budget.xlsx];

Concatenate(Temp)

LOAD

     CSC#,

     CSC,

     Parts as Actual_Parts,

     Tires,

     Tools,

     Physical_Damages,

    Supplies,

     'Actuals' as Source

FROM [Data\Budget.xlsx];

Data:

LOAD *,

     RangeSum(Budget_Parts, - Actual_Parts) as Total

Resident Temp;


DROP TABLE Temp;



OR


Temp: 

LOAD

     CSC#,

     CSC,

     Parts as  Budget_Parts,

     Tires,

     Tools

FROM [Data\Budget.xlsx];

LEFT JOIN(Temp)

LOAD

     CSC#,

     CSC,

     Parts as Actual_Parts,

     Tires,

     Tools,

     Physical_Damages,

    Supplies

FROM [Data\Budget.xlsx];

Data:

LOAD *,

     Rangesum(Budget_Parts, - Actual_Parts) as Total

Resident Temp;


DROP TABLE Temp;


Hope this helps you.


Regards,

jagan.