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: 
berryandcherry6
Creator II
Creator II

Error: Invalid Expresion. In Load Script using Firstsortedvalue function

Hi,

I have more than one lender_offer_id for single User_id. So i need to get latest lender_offer_id of that particular user_id. and

I am trying to execute below code, but giving me Error: Invalid Expression

OLD:

LOAD `user_id`,

    `batch_meta_data_id`,

    `lender_offer_id`,

    `course_completed`,

    `date_completed`,

    `date_created` as Course_Date;

SQL SELECT `user_id`,

    `batch_meta_data_id`,

    `lender_offer_id`,

    `course_completed`,

    `date_completed`,

    `date_created`      // date created lender_offer

FROM dfgt.COURSECOMPLETION;

New:

LOAD `user_id` as new_User,

    `batch_meta_data_id` as New_batch,

    firstsortedvalue(lender_offer_id,-lender_offer_id) as New_lender,

    `course_completed` as New_Course,

    `date_completed` as New_Date_completed,

    `Course_Date` as New_Course_Date

    resident OLD

     Group by lender_offer_id;

  drop table OLD;

any help is appreciated.

2 Replies
Not applicable

Hi Supriya,

Firstsorted value acts similar to Aggregate functions, so every field which is outside of firstsorted value must go inside the group by clause.

Based on your requirement try  below steps

New:

Load

user_id,

firstsortedvalue(lender_offer_id,-lender_offer_id) as Newlender

Resident Old

group by user_id;

Later add other fields as required and then drop the table,

Try to use this and see if it works..

miskin_m
Partner - Creator
Partner - Creator

Hi

You need to group by all fields and not just lender_offer_id