Qlik Community

QlikView Creating Analytics

Discussion Board for collaboration related to Creating Analytics for QlikView.

washington
Contributor

Interval between dates.

I have a table of stock and need to know the input frequency. I'm not having idea how to do this on the table.

The INPUT field is the starting point.

      DATA          INICIAL       ENTRADA      SAIDA       FINAL     DIAS
01/06/201223,000,000,0023,00
02/06/201223,000,000,0023,00
03/06/201223,000,000,0023,00
04/06/201223,000,000,0023,00
05/06/201223,000,007,0016,00
06/06/201216,000,000,0016,00
07/06/201216,000,000,0016,00
08/06/201216,0050,000,0066,00           8,00
09/06/201266,000,000,0066,00
10/06/201266,000,000,0066,00
11/06/201266,000,000,0066,00
12/06/201266,000,001,0065,00
13/06/201265,000,002,0063,00
14/06/201263,000,000,0063,00
15/06/201263,000,000,0063,00
16/06/201263,000,000,0063,00
17/06/201263,000,000,0063,00
18/06/201263,000,000,0063,00
19/06/201263,000,000,0063,00
20/06/201263,000,000,0063,00
21/06/201263,000,000,0063,00
22/06/201263,000,000,0063,00
23/06/201263,000,000,0063,00
24/06/201263,000,000,0063,00
25/06/201263,0030,000,0093,00         17,00
26/06/201293,000,000,0093,00
27/06/201293,000,006,0087,00
28/06/201287,000,000,0087,00
29/06/201287,000,000,0087,00
7 Replies
MVP
MVP

Re: Interval between dates.

I assume you should be able to calculate the date difference in the script, maybe like adding this to your script:

Let vStartDate = num(peek('DATA',0,'INPUT'));

LEFT JOIN LOAD DATA, rangesum(DATA,-rangemax(peek('DATA'),$(vStartDate)-1)) as DELTA resident INPUT where ENTRADA >0;

Hope this helps,

Stefan

washington
Contributor

Re: Interval between dates.

I see that the scrip worked.

But how to do this is with some function in the graph?

I have other fields that are not in the above table that when filtered has to do the calculation "on line".

MVP
MVP

Re: Interval between dates.

You can try a chart expression with set analysis and advanced aggregation like

=only({<ENTRADA={">0"}>} aggr(rangesum(only({<ENTRADA={">0"}>}DATA),-rangemax(above(total only({<ENTRADA={">0"}>}DATA)),$(vStartDate)-1)), DATA))

washington
Contributor

Re: Interval between dates.

Its function was successful.

But when I add another field as dimenssão she is not certain.

DATAEMPRESAINICIALENTRADASAIDAFINAL
36330938422
04/06/20122230023-
05/06/20122230716-
13/06/20122650263-
16/06/20122630063-
17/06/20122630063-
20/06/20122630063-
25/06/20122633009322

 

LOAD

* INLINE [
DATA, INICIAL, ENTRADA, SAIDA, FINAL, EMPRESA
01/06/2012, "23,00", "0,00", "0,00", "23,00", 1
02/06/2012, "23,00", "0,00", "0,00", "23,00", 1
03/06/2012, "23,00", "0,00", "0,00", "23,00", 1
04/06/2012, "23,00", "0,00", "0,00", "23,00", 2
05/06/2012, "23,00", "0,00", "7,00", "16,00", 2
06/06/2012, "16,00", "0,00", "0,00", "16,00", 1
07/06/2012, "16,00", "0,00", "0,00", "16,00", 1
08/06/2012, "16,00", "50,00", "0,00", "66,00", 3
09/06/2012, "66,00", "0,00", "0,00", "66,00", 3
10/06/2012, "66,00", "0,00", "0,00", "66,00", 4
11/06/2012, "66,00", "0,00", "0,00", "66,00", 1
12/06/2012, "66,00", "0,00", "1,00", "65,00", 1
13/06/2012, "65,00", "0,00", "2,00", "63,00", 2
14/06/2012, "63,00", "0,00", "0,00", "63,00", 3
15/06/2012, "63,00", "0,00", "0,00", "63,00", 1
16/06/2012, "63,00", "0,00", "0,00", "63,00", 2
17/06/2012, "63,00", "0,00", "0,00", "63,00", 2
18/06/2012, "63,00", "0,00", "0,00", "63,00", 3
19/06/2012, "63,00", "0,00", "0,00", "63,00", 1
20/06/2012, "63,00", "0,00", "0,00", "63,00", 2
21/06/2012, "63,00", "0,00", "0,00", "63,00", 3
22/06/2012, "63,00", "0,00", "0,00", "63,00", 1
23/06/2012, "63,00", "0,00", "0,00", "63,00", 1
24/06/2012, "63,00", "0,00", "0,00", "63,00", 1
25/06/2012, "63,00", "30,00", "0,00", "93,00", 2
26/06/2012, "93,00", "0,00", "0,00", "93,00", 3
27/06/2012, "93,00", "0,00", "6,00", "87,00", 3
28/06/2012, "87,00", "0,00", "0,00", "87,00", 3
29/06/2012, "87,00", "0,00", "0,00", "87,00", 1
]

;

MVP
MVP

Re: Interval between dates.

I do get 25 returned from my expression with your new data, creating a table chart with dimensions DATA and EMPRESA, with EMPRESA = 2 selected. Not 22. Have you changed the vStartDate variable in any way?

If not, could you upload a sample that demonstrates your issue together with a description of your expected result?

washington
Contributor

Re: Interval between dates.

With the outcome variable was fixed.
Replaces the variable by the function ..
Without the new field "COMPANY" was working, now is bringing 22.
correct is 7.

She has to work according to the selection.

MVP
MVP

Re: Interval between dates.

22 seems to be ok to me if you want to calculate the time interval in days since the last update of ENTRADA (which is what I would expect if you ask for interval between dates).

It seems that you just want to count the number of dates instead, so maybe something like

=aggr(rangesum(only({<ENTRADA={">0"}>} aggr(rowno(), DATA)),-rangemax(above(only({<ENTRADA={">0"}>} aggr(rowno(), DATA))),0)),DATA)

(this returns 7 in your sample) is more appropriate.

Have a nice day,

Stefan

Community Browser