Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Not applicable

Use new create field to create another field in the same script

Hi, I have problem with using the new create field  "Tender" to create another field "PEP".

Date([Start Date]) as "Start",

Date([End Date]) as "End",

Date(IF([Start Date]='', (''), AddMonths([Start Date],-4) ) )as "Tender",


Date(IF([Budget Type]=('CAPEX'), IF([Tender]=(''), (''), AddMonths([Tender], -3) ), ('') )) as "PEP"

Capture.PNG


And it is possible to use rename field with the new name? for example instead of:

Date(IF([Start Date]='', (''), AddMonths([Start Date],-4) ) )as "Tender", can i use Date(IF([Start]='', (''), AddMonths([Start],-4) ) )as "Tender"?




5 Replies
undergrinder
Valued Contributor II

Re: Use new create field to create another field in the same script

Hi Lingling,

Date(IF([Budget Type]='CAPEX', IF([Tender]='', '', AddMonths([Tender], -3)),'')) as PEP

The quotation marks is obligate when you have two or more word long column name, at this case with "PEP" refer an existing column, PEP refer to alias.

G.

Not applicable

Re: Use new create field to create another field in the same script

Sorry, I don't get itSmiley Sad I am trying to know is it possible to use new create field  to create another field?

for example, i use formula to generate a new field known as "Tender", then i would like to create another field which make use of the "Tender"  field?

sasiparupudi1
Honored Contributor III

Re: Use new create field to create another field in the same script

use a preceding load as you can not refer to an expression as a field in the load

Table:

load *,

Date(If([Budget Type]='CAPEX', if(Tender='', '', AddMonths([Tender], -3) ), '' )) as "PEP";

LOAD *,

    Date([Start Date]) as "Start",

    Date([End Date]) as "End",

    Date(If([Start Date]='', '', AddMonths([Start Date],-4) ) )as Tender;

LOAD * INLINE [

    Budget Type,Start Date,End Date

    CAPEX        

];

sasiparupudi1
Honored Contributor III

Re: Use new create field to create another field in the same script

Short answer is NO

you can not refer the expression -> Date(IF([Start Date]='', (''), AddMonths([Start Date],-4) )


in another expression

undergrinder
Valued Contributor II

Re: Use new create field to create another field in the same script

Yes, sorry, I didn't noticed, that the Tender field is created in the same statement.

G.