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

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
harleen_singh
Creator III
Creator III

I am using correct script??

I don't know where i am wrong in this script??

LOAD date,

     v,

     Max(date) as maximumdate

FROM

table

thanks

Lavi

15 Replies
kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

   As per my knowledge its not possible to have date, max(date) together.

   Let me explain.

   Cosider you have data like this

   date         v

  10/7/2011  1

  11/7/2011  2

  12/7/2011  3

  10/8/2011  4

  11/8/2011  5

  12/8/2011  6

  So here max of date will be 12/08/2011

  but according to your requirement i.e you want Date Max(Date) and v

  this will give you the result like this only.

 

   date         Max(Date)    v

  10/7/2011 10/7/2011  1

  11/7/2011 11/7/2011  2

  12/7/2011 12/7/2011  3

  10/8/2011 10/8/2011  4

  11/8/2011 11/8/2011  5

  12/8/2011 12/8/2011  6

   i hope you understood what i mean to say.

   if not then please exaplain with example, give the raw data as well as the output you want.

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
harleen_singh
Creator III
Creator III
Author

kaushik

raw data is same u have written

i want output like this

date         Max(Date)    v

  10/7/2011 12/8/2011  1

  11/7/2011 12/8/2011  2

  12/7/2011 12/8/2011  3

  10/8/2011 12/8/2011  4

  11/8/2011 12/8/2011  5

  12/8/2011 12/8/2011  6

perumal_41
Partner - Specialist II
Partner - Specialist II

use this script ;Check is correct or not

LOAD date,

     v

   FROM

table

left Join

load v,max(Date) as MaxDate

     from table

    group by v;

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

HI,

   Try this script.

Data:

load * inline [

date, v

10/7/2011, 1

11/7/2011, 2

12/7/2011, 3

10/8/2011, 4

11/8/2011, 5

12/8/2011, 6

];

Max:

load

max(date) as MaxDate

Resident Data ;

 

let Max_Date = peek('MaxDate',0,'Max');

 

Data1:

load

date as Date,

date($(Max_Date)) as Max_Date,

v as V

Resident Data;

Drop table Data, Max;

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
harleen_singh
Creator III
Creator III
Author

Kaushik

             thanks this is correct but again when i am clicking on max_date corresponding data is not changing according to maximum date.

click on max_date in attach file u will know

thanks

Lavi

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

   Its is selecting corresponding data.

   I will explain you how it works.

   See now you got result as

  

   date         Max(Date)    v

  10/7/2011 12/8/2011  1

  11/7/2011 12/8/2011  2

  12/7/2011 12/8/2011  3

  10/8/2011 12/8/2011  4

  11/8/2011 12/8/2011  5

  12/8/2011 12/8/2011  6

   right..?

 

   So you will have 3 fields i.e Date which will have values from 10/7/2011 to 12/08/2011

   Second field will be Max(Date) which will have only one value i.e 12/08/2011

   and third will be v which will have 1 to 6.

   Now as you said when you like on 12/08/2011 nothing is selected in Date and Value field.

   so even if you select max(date) there will be no change on other field and vice versa.

 

    The reason is max(date) is available in all fileds and max(date) is having only one value.

   If incase you had data like this.

date         Max(Date)    v

  10/7/2011 12/7/2011  1

  11/7/2011 12/7/2011  2

  12/7/2011 12/7/2011  3

  10/8/2011 12/8/2011  4

  11/8/2011 12/8/2011  5

  12/8/2011 12/8/2011  6

    Then your max(date) field will have two values and now the selection in max(date) will effect the other fields too.

   But you cant use the same script to get the data shown above. You need to think on it to get the same data as shown above.

   I hope your doubt is clear now.

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!