Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi
I have a column containing sensor values at the start of each month.
e.g.
equipment | month | sensor value |
001 | jan-2019 | 1000 |
001 | feb-2019 | 1100 |
001 | mar-2019 | 1150 |
002 | jan-2019 | 2000 |
002 | feb-2019 | 2250 |
002 | mar-2019 | 2600 |
I want to obtain the difference between the sensor value of each month for each equipment.
The results should be as follows:
equipment | month | monthly hours |
001 | jan-2019 | 100 |
001 | feb-2019 | 50 |
001 | mar-2019 | - |
002 | jan-2019 | 250 |
002 | feb-2019 | 350 |
002 | mar-2019 | - |
Does anyone know how to do this in the data load editor?
Thanks,
Roisin
Try like:
t1:
LOAD equipment,
date#(month, 'MMM-YYYY') as month,
[sensor value]
FROM
[https://community.qlik.com/t5/New-to-Qlik-Sense/Finding-the-difference-between-values-based-on-month/td-p/1674704]
(html, utf8, UserAgent is 'Mozilla/5.0', embedded labels, table is @1);
t2:
Load
*,
If(equipment=peek(equipment), RangeSum(-[sensor value],peek([sensor value]))) as [monthly hours]
Resident t1 order by equipment, month Desc;
Drop Table t1;
Try like:
t1:
LOAD equipment,
date#(month, 'MMM-YYYY') as month,
[sensor value]
FROM
[https://community.qlik.com/t5/New-to-Qlik-Sense/Finding-the-difference-between-values-based-on-month/td-p/1674704]
(html, utf8, UserAgent is 'Mozilla/5.0', embedded labels, table is @1);
t2:
Load
*,
If(equipment=peek(equipment), RangeSum(-[sensor value],peek([sensor value]))) as [monthly hours]
Resident t1 order by equipment, month Desc;
Drop Table t1;
Thank you very much for your help Tresesco, that worked perfectly!
Regards,
Roisin