Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Distribute grouped values for periods of daily values

Hello everyone, I need your help to spread the values that are part of a range of dates, to daily values.
Enclosed is an example of what I'd need.
my data source is a single file QVD with the fields as in the Excel.
To consider that my total assets are about 450.
Thanks to those who can help me

1 Solution

Accepted Solutions
sunny_talwar

Try this:

Table:

LOAD asset,

    Date(Floor(data)) as date,

    delta

FROM

[targhe2.xlsx]

(ooxml, embedded labels, table is Sheet1);

tmpTable:

LOAD *

Where Not(delta = 0 and Flag > 1);

LOAD *,

  AutoNumber(RecNo(), asset) as Flag,

  Date(If(asset = previous(asset), Peek('date') + 1, date)) as startdate

Resident Table

Order By asset, date;

FinalTable:

LOAD Date(startdate + IterNo() - 1) as date,

  delta/(date - startdate + 1) as value,

  asset

Resident tmpTable

While startdate + IterNo()-1 <= date;

DROP Tables Table, tmpTable;

View solution in original post

14 Replies
sunny_talwar

These belong to different id... the final output will only have the three columns you have specified?? or those will repeat just like repeating value??

Capture.PNG

Not applicable
Author

I need a new QVD with three fields.

sunny_talwar

Try this

Table:

LOAD asset,

    date,

    avg

FROM

[..\..\..\Downloads\targhe1.xlsx]

(ooxml, embedded labels, table is Foglio1);

tmpTable:

LOAD *,

  Date(If(asset = previous(asset), Peek('date') + 1, date)) as startdate

Resident Table;

FinalTable:

LOAD Date(startdate + IterNo() - 1) as date,

  avg as value,

  asset

Resident tmpTable

While startdate + IterNo()-1 <= date;

DROP Tables Table, tmpTable;

Not applicable
Author

the final work is definitely what you need me. Unfortunately   I was a bit inaccurate to ask the question because the avg field is not present in the original QVD but should first be averaged and then should apply your current processing

sunny_talwar

What are we averaging? How does the raw data look like?

Not applicable
Author

- To group together assets;
- Ordered by date;
- The average (avg) is given from the delta area, divided by the difference in days between the date referred to by the value and the previous date.

idassetlocationmeternamedeltadateavgmode calculating avg
292085AAAAAAAAUTOPARCOCHILOMETRI016/01/2014nulldelta (0) / null _________ (16/01/2014 - null)
293766AAAAAAAAUTOPARCOCHILOMETRI23519/02/20146.911765delta (235) / 34 ___________(19/02/2014 - 16/01/2014)
294590AAAAAAAAUTOPARCOCHILOMETRI28407/03/201417.75delta (284) /16________ (07/03/2014 - 19/02/2014)
294669AAAAAAAAUTOPARCOCHILOMETRI5110/03/201417delta (51) /3_______ (10/03/2014 - 07/03/2014)
sunny_talwar

Try this:

Table:

LOAD asset,

    date,

    delta

FROM

[..\..\..\Downloads\targhe1.xlsx]

(ooxml, embedded labels, table is Foglio1);

tmpTable:

LOAD *,

  Date(If(asset = previous(asset), Peek('date') + 1, date)) as startdate

Resident Table;

FinalTable:

LOAD Date(startdate + IterNo() - 1) as date,

  delta/(date - startdate + 1) as value,

  asset

Resident tmpTable

While startdate + IterNo()-1 <= date;

DROP Tables Table, tmpTable;

Not applicable
Author

I take advantage of your kindness ....
The drawing is fine if the asset field I only have a unique value, but I have problems when loading a source (as attached) with many different assets. Or rather, if I high daily values do not coincide with grouped delta.


In your opinion, you can delete the lines that have to be calculating delta zero?

sunny_talwar

Not sure I understand this:

In your opinion, you can delete the lines that have to be calculating delta zero?

Can you check if this works?

Table:

LOAD asset,

    Date(Floor(data)) as date,

    delta

FROM

[targhe2.xlsx]

(ooxml, embedded labels, table is Sheet1);

tmpTable:

LOAD *,

  Date(If(asset = previous(asset), Peek('date') + 1, date)) as startdate

Resident Table

Order By asset, date;

FinalTable:

LOAD Date(startdate + IterNo() - 1) as date,

  delta/(date - startdate + 1) as value,

  asset

Resident tmpTable

While startdate + IterNo()-1 <= date;

DROP Tables Table, tmpTable;