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: 
Not applicable

Problem with last value

Hello,

I have a question for you:

I have a straight table with columns:

PHONE_CODE, KPI .. etc.

For every year-week I have a different kpi.

The problem is that for every PHONE_CODE, I have multiple lines, as I have multiple KPI values (multiple calendar dates).

How can I display only the last value of Kpi, the value of last week in selection?

Thank YOU!

7 Replies
kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

     I am not clear about your problem.

     Kindly explain with example and if possible post your qvw file.

Regards,

Kaushik Solanki

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

Hi,

I have :

PHONE_CODE, KPI, ..........

CODE1, 1 ............... (for 2012-1),

CODE1, 2 ............... (for 2012-2),

CODE1, 3...............  (for 2012-3),

CODE1, 4 ............... (for 2012-4)

in straight table.

I want to have:

CODE1,4 in my table ->last value of KPI for year-week for a given CODE.

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

     Kindly share your application and also tell us what should be the output.

Regards,

Kaushik Solanki

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

Thank you very much for your help, but, unfortunatelly I cannot share the app..

What I want to achive : transform table from :

PHONE_CODE, KPI (kpi's for consecutive weeks)

CODE1, 1

CODE1, 2

CODE1,3

CODE1,4

into:

PHONE_CODE, KPI (kpi's for consecutive weeks)

CODE1,4

I want to display only the last value  in time for KPI.

I tried last(kpi), but doesn't work-> 'error in calculation'

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

     If you have this table in script then you can try this.

     TEMP:

     Load Max(KPI),PHONE_CODE,PHONE_CODE&'-'&Max(KPI) as KEY

     from xyz group by PHONE_CODE;

     DATA:

     Load *

     from xyz

     where exists(KEY,PHONE_CODE&'-'&KPI);

     So what I am trying to do is find the max KPI for each of the PhoneCode and then load only data for them.

Regards,

Kaushik Solanki

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

Thx for reply, but I don't need the max of kpi..

Kpi can be: 1,2,3,4,5,2.

In my case the correct value will be 2, the last one. Not 5, the max one.

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

     Then try this code to get the last record of the table.

     TEMP:

     Load Distinct KPI,PHONE_CODE from xyz.

     Let vLastKPI = peek('KPI',-1,'TEMP');

     Let vLastPHONE = peek('PHONE_CODE',-1,'TEMP');

     Data:

     Load * from xyz where KPI = $(vLastKPI) and PHONE_CODE = $(vLastPHONE);

     Drop table Temp;

Regards,

Kaushik Solanki

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