Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
lessassy
Creator
Creator

Use of previous in a script (doesn't work)

Hello everyone,

 

I'm loading data from a SAP BO Database using this script

LIB CONNECT TO 'DATABASE';

// LOAD YEAR,
// MONTH,
// ID,
//  VALUE,
f;

// [DATA_KPI]:
// SELECT "ANNEE",
// "MOIS",
// "MATRICULE",
// "EFF_FINMOIS"
// FROM "BO"."DATABASE";


// // KPI_TABLE:
// // LOAD*,
// // if(ID = Previous(ID) and ANNEE = Previous(YEAR)+1
// // and MOIS = Previous(MONTH) and VALUE >0 and Previous(VALUE)>0, 1, 0) as PermanentStaff
// // Resident [DATA_KPI];
// // Drop Table[DATA_KPI];

 

But it doesn't work.

I'm trying to check the record from current year and previous year looking at the ID. If the ID exist in previous period and current period and if there is data in the previous period and the current period and the month from last year and the month fro this year then it's pemanent staff.

But i always get 0 from permanent staff which i don't understand.

Anyone could help ?

Please.

Thanks

Labels (1)
2 Replies
chrismarlow
Specialist II
Specialist II

Hi,

Is there any reason the script has comment tags on it (//)?

A (single) Previous statement looks at the row before in your load, so if there are monthly records for each ID I am not sure you are going to be able to use this to assign PermanentStaff if your criteria cover a number of rows between months and years, but I am not sure I understand your requirement.

Are you able share some (anonymised) data and how you would tag it up?

Cheers,

Chris.

marcus_sommer

I think your resident-load missed a proper order by statement - means you need to sort the load to ensure that they are loaded within a proper way.

- Marcus