Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

IF/MAX statement help needed

am trying to get the following IF statement to work, and I'm not sure this is possible and if so, what I'm doing wrong. I have a couple of questions. Do I need a Group By function added to this? If so, where, because I've tried it several ways. Also, can this even be done the way I'm trying to do things?

GPAStatusTbl:
SQL SELECT * FROM SYSADM."PS_W_GPA_STS_TBL";
STORE * FROM GPAStatusTbl INTO $(vQVDFolder)\GPAStatusTbl.qvd;
DROP TABLE GPAStatusTbl;
LOAD
"W_GPA_ID" AS [IHR GPA ID],
ACTIONDTTM,
"W_GPA_STATUS",
IF(W_GPA_STATUS = 'IHV', MAX (ACTIONDTTM)) AS IHR_APP_1_DATE
FROM $(vQVDFolder)\GPAStatusTbl.qvd (qvd);


Thanks!

Labels (1)
1 Reply
disqr_rm
Partner - Specialist III
Partner - Specialist III

Try: MAX(IF(W_GPA_STATUS = 'IHV', ACTIONDTTM)) AS IHR_APP_1_DATE

And yes, you would need to group it by first 3 fields.

EDIT: And I think you need to use MAXSTRING and not MAX as W_GPA_STATUS seems to be a string.