Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
One of the developer working on my Qlik Sense site gets the error "Invalid expression" with this following query:
Load ID_DOC, if (num(STARTDATE) =Max (STARTDATE), 'LastWKF', 'OldWKF') as WKFREV
Do you have any lead?
Regards
Hi,
It's a script expression. You are using a Max() function, you need a group by:
Load
ID_DOC,
if (num(STARTDATE) =Max (STARTDATE), 'LastWKF', 'OldWKF') as WKFREV
Resident MyTable
Group By
ID_DOC
;
Hello Thanks for your answer.
Sorry I forgoit to give the entire express on my previous post.
If fact, the developper is well using a group by and got the error:
Here teh full expression:
Join (WKF)
Load ID_DOC
,if(num(STARTDATE) =Max(STARTDATE),'LastWKF', 'OldWKF') as WKFREV
resident DOC
Group by ID_DOC
;
Any clue on where the error may be from?
Thanks in advance.
DGE
Hi,
I think you can't use this expression in your case: num(STARTDATE)=Max(STARTDATE)
For num(STARTDATE) you need to add STARTDATE in your group by, but if you do that Max(STARTDATE) return STARTDATE.
You can do in two step.
left join(DOC)
Load
ID_DOC,
Max(STARTDATE) as STARTDATE,
Max(STARTDATE) as MAXDATE
resident DOC
Group by ID_DOC
;
Join (WKF)
Load
ID_DOC,
if(not isNull(MAXDATE),'LastWKF', 'OldWKF') as WKFREV
resident DOC
;
drop field MAXDATE;
Hi Aurélien,
Thanks for your answer which has been submitted to the developer.
I will let you know as soon as i get his answer.
Best regard.
DG