Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
varmekontrol
Creator
Creator

Peek not working as intenden when using it for consumption by date.

HI 

I am pulling the last of my hair out of my head because of this. 
Hope you can help me figure out what is wrong. 

I am creating a QVD file with this. 

Heat_meter_qvd:
LOAD Num(@1) as Cme_no, 
     Num(@2) as Meter_no, 
     date(@3, 'YYYY-MM-DD hh:mm') as Created,
     num(@8/1000) as Energy_wH,
     Num(@9) as Volume_m3, 
     Num(@10) as Volume_flow_m3H, 
     Num(@12) as Flow_temp_C, 
     Num(@13) as Return_temp_C,
     num(@12-@13) as Temp_diff_C

FROM
[D:\HeatMeter\*.csv]
(txt, codepage is 28591, no labels, delimiter is ';', msq, header is 1 lines where Date(@3)>=today()-7;

STORE  Heat_meter_qvd into "C:\Heat_meter.qvd" (qvd);
Drop Table Heat_meter_qvd;

From that QVD I am importing a table and calculating the peek from the previous date (Consumption) 
FYI - It has been working since I made it a couple of days ago, and now it just stopped and have 0 consumption. 

Heat_meter_temp_1:
LOAD Cme_no, 
     num(Meter_no,'00000000') as  Meter_no,
     Created,
     Energy_wH, 
     Volume_m3, 
     Volume_flow_m3H, 
     Flow_temp_C, 
     Return_temp_C, 
     Temp_diff_C
FROM
[C:\Heat_meter.qvd]
(qvd);

Heat_meter_temp_2: 
NoConcatenate
LOAD *,
	 peek('Energy_wH') as Energy_wH_peek,
	 num(((Energy_wH-peek('Energy_wH'))),'#####,00') as Energy_wH_consumption,
	 peek('Volume_m3') as Volume_m3_peek,
	 num(((Volume_m3-peek('Volume_m3'))),'#####,00') as Volume_m3_consumption	 
Resident Heat_meter_temp_1 order by Meter_no, Created;

Drop Field Energy_wH_peek, Volume_m3_peek;
Drop Table Heat_meter_temp_1;

Heat_meter:
NoConcatenate
Load *   	
Resident Heat_meter_temp_2 where Energy_wH_consumption>=0 and Volume_m3_consumption>=0;

Drop Table Heat_meter_temp_2;

My result is this. 

Cme_no Meter_no Created Energy_wH wH_consump Volume_m3 m3_consump 
120552186872766921-03-2019 00:004165301389,650
120552186872766921-03-2019 00:3041654 1389,67 
120552186872766921-03-2019 01:004165401389,69 
120552186872766921-03-2019 01:304165401389,71 
120552186872766921-03-2019 02:0041655 1389,73 
120552186872766921-03-2019 02:304165501389,76 
120552186872766921-03-2019 03:0041656 1389,78 
120552186872766921-03-2019 03:304165601389,8 
120552186872766921-03-2019 04:0041657 1389,82 
120552186872766921-03-2019 04:304165701389,84 
120552186872766921-03-2019 05:004165701389,86 
120552186872766921-03-2019 05:3041658 1389,88 
120552186872766921-03-2019 06:004165801389,91 
120552186872766921-03-2019 06:3041659 1389,93 
120552186872766921-03-2019 07:004165901389,95 
120552186872766921-03-2019 07:3041660 1389,98 
120552186872766921-03-2019 08:004166001389,99 
120552186872766921-03-2019 08:3041662 1390,04 
120552186872766921-03-2019 09:0041663 1390,06 
120552186872766921-03-2019 09:304166301390,08 
120552186872766921-03-2019 10:004166301390,1 

 

16 Replies
sunny_talwar

So, these look like the same csv files you shared before, right? What I meant was the I see in your csv file there is a field called #serial-number... what does this corresponds to in your main dashboard... because this is what you are loading from the csv

Num(@1) as Cme_no, 
     Num(@2) as Meter_no, 
     date(@3, 'YYYY-MM-DD hh:mm') as Created,
     num(@8/1000) as Energy_wH,
     Num(@9) as Volume_m3, 
     Num(@10) as Volume_flow_m3H, 
     Num(@12) as Flow_temp_C, 
     Num(@13) as Return_temp_C,
     num(@12-@13) as Temp_diff_C
varmekontrol
Creator
Creator
Author

Not sure if this is what you need? 

image.png

 

     Num(@1) as Cme_no,  (#serial-number)
     Num(@2) as Meter_no,  (device-identification) 
     date(@3, 'YYYY-MM-DD hh:mm') as Created, (created)
     num(@8/1000) as Energy_wH, (energy,Wh,inst-value,0,0,0)
     Num(@9) as Volume_m3, (volume,m3,inst-value,0,0,0)
     Num(@10) as Volume_flow_m3H, (volume-flow,m3/h,inst- value,0,0,0)                                                              
     Num(@12) as Flow_temp_C,  (flow-temp,°C,inst-value,0,0,0)
     Num(@13) as Return_temp_C, (return-temp,°C,inst-value,0,0,0)
     num(@12-@13) as Temp_diff_C

 

 

 

sunny_talwar

Yes, thank you

sunny_talwar

Can you check if the attached looks good

varmekontrol
Creator
Creator
Author

Hi Sunny

Thank you for your patience, that did the trick, and I also learned a way to validate that the peek() is done on the right fields every time.. 

Thx a million 🙂 

Heat_meter_temp_2: 
NoConcatenate
LOAD *,
	 peek('Energy_wH') as Energy_wH_peek,
	 If(Cme_no = Previous(Cme_no) and Meter_no = Previous(Meter_no), num(((Energy_wH-peek('Energy_wH'))),'#####,00'), Num(0,'#####,00')) as Energy_wH_consumption,
	 peek('Volume_m3') as Volume_m3_peek,
	 If(Cme_no = Previous(Cme_no) and Meter_no = Previous(Meter_no), num(((Volume_m3-peek('Volume_m3'))),'#####,00'), Num(0,'#####,00')) as Volume_m3_consumption	 
Resident Heat_meter_temp_1
order by Cme_no, Meter_no, Created;
mybkexperience
Contributor
Contributor

With MyBKExperience research, Burger King wants to inspect customers and get their feedback.

sunny_talwar

lol that is great... what does that have to do with Qlik?