Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Announcements
Qlik® Product Spotlight: Discover what’s possible. Get more from our products.
See for yourself. Register today.
Not applicable

custom counter in load script

Hi,

Please help me.

I am trying to run a custom counter using a variable 'x' with incremental value 1 within a load scripts which is loading data from a resident table .

Please someone respond. It's urgent.

Thank You,

Rahul Krishan Goyal

11 Replies
brunobertels
Not applicable

Re: custom counter in load script

not sure about what you need exactly but have a look at autonumber function

can be somethink like that :

LOAD

if(sales>0,autonumber("date"))as ID,

// rangesum(sales,0,RowNo()) as cumul_vente,

    "date",

    sales

FROM [lib://Help Test/autonumber.xls]

(biff, embedded labels, table is Feuil1$);

Not applicable

Re: custom counter in load script

Hi  Bruno,

Thanks so much for the response.

I am actually looking to run a custom counter using a variable with incremental value 1 within a load statement loading data from a resident table. 

I should be able to set value for the counter.

Please help,

Not applicable

Re: custom counter in load script

In autonumber function, you cannot control the next value. While I want to set value to zero on a particular if condition and want to restart the value with 1.

Thanks,

sunny_talwar
Not applicable

Re: custom counter in load script

What exactly are you doing Rahul? You need to provide some context here... May be a sample with the expected outcome?

Not applicable

Re: custom counter in load script

Hi Sunny,

Thanks so much for the response.

Example;

I have table a

A:

Load

no,

date,

time

The table A is sorted on Name,date & time.  There a more than one records no wise and date wise.

I want to use this table as resident table for another new table having the similar sorting as table A . I want to run a counter within second load statement having resident clause  starting from 1(not using rowno() or rangesome), and, will capture counter value in a field.

I will pick all the fields from resident table A, will check the time difference for a particular no.(current time - previous tome). and, if  the difference is more than 'x' time, I want to reset the counter to zero will capture this zero value in the same field I am capturing counter values above. If the time difference is less than 'x', the counter value will remain same. The counter will restart with zero for next record from resident table.

Hope, now it is clear to you.

Thanks,

Not applicable

Re: custom counter in load script

Sunny,

I actually wants to run a custom counter within a load statement loading data from resident table so that I can manipulate the counter value based on my if conditions. Currently, I am unable to do so as my counter value does not change even after loading all the data from resident table.

Thanks,

sunny_talwar
Not applicable

Re: custom counter in load script

Seems like you need to use Peek/Previous here... Peek() vs Previous() – When to Use Each

Peek() or Previous() ?

Have you already tried those?

Not applicable

Re: custom counter in load script

Hi Sunny,

I have already gone thru the link you have sent.

'previous' function I am already using in my second load statement for comparing previous and current time.

As communicated to you, I am facing problem in running a custom counter while fetching records from a resident table.

Let's say, I have 1000 records in my table 'A', and, I want to fetch all records in second table using 'resident' and a custom counter with incremental value 1. I will manipulate the counter value based on my 'if' condition. 

Thanks,

sunny_talwar
Not applicable

Re: custom counter in load script

I kind of understand what you want Rahul, but without looking at what you have already tried or without a sample with expected output, I can only give you generic direction. If you want more help, you will have to provide me with a numeric sample (not just words) and what do you want to see in the end after the reload completes.

Does this make sense my friend?