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

Announcements
Discover how organizations are unlocking new revenue streams: Watch here
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

why max() ?

Hello,

in this case:


costs:
Load *Inline [
dataCost , costAmount
'01/07/2009' , 10000
'01/08/2009' ,50000
];

load
Max(date(date#(dataCost, 'DD/MM/YYYY'))) as endPeriod ,
costAmount
resident
costs
group by dataCost, costAmount ;

endPeriod outpi = '01/07/2009' and 01/08/2009

nothing happens? return 2 date and not the max date 01/08/2009

I would obtain HUSt a max date = 01/08/2009

please help me.

thanks, best regards

Sl

8 Replies
Anonymous
Not applicable
Author

Try
group by costAmount

Not applicable
Author

it doesn't work r.

return 2 date and i aspect 1 date the max and so 01/08/2009 ...

prieper
Master II
Master II

Hi,

you need to calculate the max. value and then join it across all records.
Second part of the script should read:

JOIN (costs) load
Max(date(date#(dataCost, 'DD/MM/YYYY'))) as endPeriod
resident
costs;

HTH

Peter

Anonymous
Not applicable
Author

Sure, what I was thinking...

It returns max per each costAmount. You need simply

load
Max(date(date#(dataCost, 'DD/MM/YYYY'))) as endPeriod
resident cost;

Not applicable
Author

ok, now works please O f I would to convert this field endPeriod to a variable is it possible?

Thanks

Slasj

prieper
Master II
Master II

Hi,

would be a construct like

MaxTable: LOAD MAX(YourDate) AS MaxDate RESIDENT YourTable;

LET vMax = PEEK('MaxDate', 0, 'MaxTable');

HTH

Peter

Anonymous
Not applicable
Author

Yes:

LET vEndPeriod = peek('endPeriod');
And, after this you can drop the field, if you use Peter's approach, or the table where the field is, if you use mine.

Not applicable
Author

Thaks at All

Stick out tongue

Best Regards

Slash