Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
Qlik Analytics Tour 2020 Online. Begins August 10th. Register Today
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Creator II
Creator II

Renaming a field in the same load script

Hello Guys,

My script looks like this:

SPT_AUDIT_EVENT:

[Removed Roles],

[Removed Entitlements]

FROM [..\..\QVD\MyTable.qvd] (qvd);

ASAR_Table:

Load

Trim([ASAR Removal Type]) As [Removal Type],

Trim([ASAR Event Trigger]) As [ASAR Trigger],

Trim([Removed Roles]) As [ASAR Roles],

Trim([Removed Entitlements]) As [ASAR Entitlements],

SubStringCount([ASAR Roles],'chr(10)') As roleCount1,

SubStringCount([ASAR Entitlements],'chr(10)') As EntCount1

Resident SPT_AUDIT_EVENT;

Whenever I run the script , it says it cant find [ASAR Roles]. Is it because I cant rename a field in the same table?

1 Solution

Accepted Solutions
Highlighted
Champion III
Champion III

Re: Renaming a field in the same load script

Yes you cannot rename the field in same load and use that renamed field in the same load. So try like resident load as below:

ASAR_Table:

LOAD *,

SubStringCount([ASAR Roles],'chr(10)') As roleCount1,

SubStringCount([ASAR Entitlements],'chr(10)') As EntCount1;

Load

Trim([ASAR Removal Type]) As [Removal Type],

Trim([ASAR Event Trigger]) As [ASAR Trigger],

Trim([Removed Roles]) As [ASAR Roles],

Trim([Removed Entitlements]) As [ASAR Entitlements]

Resident SPT_AUDIT_EVENT;

View solution in original post

5 Replies
Highlighted
Champion III
Champion III

Re: Renaming a field in the same load script

Yes you cannot rename the field in same load and use that renamed field in the same load. So try like resident load as below:

ASAR_Table:

LOAD *,

SubStringCount([ASAR Roles],'chr(10)') As roleCount1,

SubStringCount([ASAR Entitlements],'chr(10)') As EntCount1;

Load

Trim([ASAR Removal Type]) As [Removal Type],

Trim([ASAR Event Trigger]) As [ASAR Trigger],

Trim([Removed Roles]) As [ASAR Roles],

Trim([Removed Entitlements]) As [ASAR Entitlements]

Resident SPT_AUDIT_EVENT;

View solution in original post

Highlighted

Re: Renaming a field in the same load script

You can rename field in same table but you cannot use renamed field in same load.

So as suggested you can use preceding load  or resident load, or use original field name in new calculation

like

1: Preceding load

ASAR_Table:

LOAD *,

SubStringCount([ASAR Roles],'chr(10)') As roleCount1,

SubStringCount([ASAR Entitlements],'chr(10)') As EntCount1;

Load

Trim([ASAR Removal Type]) As [Removal Type],

Trim([ASAR Event Trigger]) As [ASAR Trigger],

Trim([Removed Roles]) As [ASAR Roles],

Trim([Removed Entitlements]) As [ASAR Entitlements]

Resident SPT_AUDIT_EVENT;

2: Using Resident Load

ASAR_Table:

Load

Trim([ASAR Removal Type]) As [Removal Type],

Trim([ASAR Event Trigger]) As [ASAR Trigger],

Trim([Removed Roles]) As [ASAR Roles],

Trim([Removed Entitlements]) As [ASAR Entitlements]

SubStringCount([ASAR Roles],'chr(10)') As roleCount1,

SubStringCount([ASAR Entitlements],'chr(10)') As EntCount1

Resident SPT_AUDIT_EVENT;

Noconcatenate

ASAR_Table_Final:

LOAD *,

SubStringCount([ASAR Roles],'chr(10)') As roleCount1,

SubStringCount([ASAR Entitlements],'chr(10)') As EntCount1;

Resident ASAR_Table;



3: Using same field in calculation

ASAR_Table:

Load

Trim([ASAR Removal Type]) As [Removal Type],

Trim([ASAR Event Trigger]) As [ASAR Trigger],

Trim([Removed Roles]) As [ASAR Roles],

Trim([Removed Entitlements]) As [ASAR Entitlements]

SubStringCount(Trim([Removed Roles]),'chr(10)') As roleCount1,

SubStringCount(Trim([Removed Entitlements]),'chr(10)') As EntCount1

Resident SPT_AUDIT_EVENT;

Regards,

Great dreamer's dreams never fulfilled, they are always transcended.
Highlighted
Specialist
Specialist

Re: Renaming a field in the same load script

It's because the field [ASAR Roles] doesn't exist in table [SPT_AUDIT_EVENT]. In other words, you are trying to LOAD [ASAR Roles] from [SPT_AUDIT_EVENT].

Highlighted
Creator II
Creator II

Re: Renaming a field in the same load script

Thanks . This makes sense.

Highlighted
Creator II
Creator II

Re: Renaming a field in the same load script

Thank you .