Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
nevilledhamsiri
Specialist
Specialist

Ability to write an expression over created field!

Hi!

As per data shown, I have created CR_MONTH after renaming CREDIT_NOTE_DATE. If I write an expression using CR_MONTH instead original filed which is CREDIT_NOTE _DATE how possible it is?  I may show you the expression written  which is as follows!

if (CR_MONTH<>TR_MONTH,1,0) as [Flag Different CR_TR_MONTH],

Hope some body may help me out.

Thanks

Neville

LOAD

BRANCH,

CLASS_CODE,

PRODUCT_CODE,

POLICY_NO,

NAME_OF_INSURED,

CREDIT_NOTE_NO,

CREDIT_NOTE_DATE,

MONTH(CREDIT_NOTE_DATE) AS CR_MONTH,

if (CR_MONTH<>TR_MONTH,1,0) as [Flag Different CR_TR_MONTH],

PERIOD_FROM,

MONTH(PERIOD_FROM) AS TR_MONTH,

PERIOD_TO,

PREMIUM,

1 Solution

Accepted Solutions
Miguel_Angel_Baeyens

The script will fail because the field CR_MONTH will only exist after the reload of the table is complete. So for the same table, your expression should look like instead:

If(Month(CREDIT_NOTE_DATE) <> Month(PERIOD_FROM), 1, 0) AS [Flag Different CR_TR_MONTH]

Or do a preceding load.

Once you do this, later in the script, then yes, you can use CR_MONTH as a field.

View solution in original post

2 Replies
Miguel_Angel_Baeyens

The script will fail because the field CR_MONTH will only exist after the reload of the table is complete. So for the same table, your expression should look like instead:

If(Month(CREDIT_NOTE_DATE) <> Month(PERIOD_FROM), 1, 0) AS [Flag Different CR_TR_MONTH]

Or do a preceding load.

Once you do this, later in the script, then yes, you can use CR_MONTH as a field.

Anil_Babu_Samineni

You can't do like above, But you may need this?

Note - If it throws error then you need to identify all the fields over preceding load because of Unique keys

Load *,

if (CR_MONTH<>TR_MONTH,1,0) as [Flag Different CR_TR_MONTH];

LOAD

BRANCH,

CLASS_CODE,

PRODUCT_CODE,

POLICY_NO,

NAME_OF_INSURED,

CREDIT_NOTE_NO,

CREDIT_NOTE_DATE,

MONTH(CREDIT_NOTE_DATE) AS CR_MONTH,

PERIOD_FROM,

MONTH(PERIOD_FROM) AS TR_MONTH,

PERIOD_TO,

PREMIUM,

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful