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

Expression gives wrong results

Hi all,

I've made an expression to calculate the average of the three month rolling sum over the past twelve months. But I have some issues with it. This is my table with values and some intermediate results (Middle table):


qlikQuestion.png

I use the following expression: 

avg( 1000*(aggr( (RangeSum(above(total count({<date={"$(='>=' & date(MonthStart(Max(date), -13)) & '<' & date(MonthStart(Max(date))))"}>} DefectType),0,3)))/
((RangeSum(above(total sum({<date={"$(='>=' & date(MonthStart(Max(date), -13)) & '<' & date(MonthStart(Max(date))))"}>} FHTime),0,3)))/60), month) ))

As you can see, I try to calculate the average of the three month rolling sum over the past twelve months of the values in the second column divided by the values in the third column. My result is only slightly off, but it's important I get a perfect result. The correct value is 180.98 while the answer i get is 177.2. 

 

Does anyone see a mistake in my expression? I'm new to Qlik so I probably missed something obvious to others.

 

Thank you!

 

Cathal

 

 

 

2 Replies
sunny_talwar

Would you be able to share a sample to check this out?

Cathalc
Contributor III
Contributor III
Author

I'm guessing you mean a sample of the data?

I'm getting my data directly from the company server so best I can do is give you the following table of original data:

 

FHKeyDefKeyACNameFHTime (minutes)DefectTypedayyearmonthdate=sum(FHTime)ATAcount(DefectType)
-43564,34245853OY-HHVOY-HHV-MAREP92019apr.09/04/20190741
08/04/2019OO-NHD-OO-NHD92-82019apr.08/04/201992-0
-43563,269176123OO-NSHOO-NSH-MAREP82019apr.08/04/20190621
-43563,661337465PH-NHVPH-NHV-MAREP82019apr.08/04/20190281
-43563,670678322TU-HNETU-HNE-PIREP82019apr.08/04/20190791
-43563,720344063OO-NSQOO-NSQ-MAREP82019apr.08/04/20190621
-43563,797983715OO-NSFOO-NSF-MAREP82019apr.08/04/20190621
-43563,807737384OO-NSFOO-NSF-MAREP82019apr.08/04/20190641
-43563,6704403949G-NHH9G-NHH-MAREP82019apr.08/04/20190341
07/04/2019OO-NHA-OO-NHA19-72019apr.07/04/201919-0
07/04/2019OO-NSF-OO-NSF96-72019apr.07/04/201996-0
07/04/2019OO-NSL-OO-NSL25-72019apr.07/04/201925-0
07/04/2019OO-NSM-OO-NSM15-72019apr.07/04/201915-0
07/04/2019OO-NSM-OO-NSM27-72019apr.07/04/201927-0
07/04/2019OO-NSM-OO-NSM70-72019apr.07/04/201970-0
07/04/2019OO-NSZ-OO-NSZ54-72019apr.07/04/201954-0
07/04/2019OY-HHV-OY-HHV44-72019apr.07/04/201944-0
07/04/2019OY-HHV-OY-HHV101-72019apr.07/04/2019101-0
07/04/2019OY-HLV-OY-HLV114-72019apr.07/04/2019114-0
07/04/2019PH-NHU-PH-NHU51-72019apr.07/04/201951-0
-43562,44925691OY-HVROY-HVR-MAREP72019apr.07/04/20190111
-43562,424640509OO-NSROO-NSR-MAREP72019apr.07/04/20190721
-43562,468705058OO-NSZOO-NSZ-MAREP72019apr.07/04/20190631
-43562,479707604PH-NHVPH-NHV-MAREP72019apr.07/04/20190281
-43562,651205752PH-NHVPH-NHV-MAREP72019apr.07/04/20190641
06/04/2019OO-NHA-OO-NHA27-62019apr.06/04/201927-0
06/04/2019OO-NHA-OO-NHA37-62019apr.06/04/201937-0
06/04/2019OO-NHA-OO-NHA59-62019apr.06/04/201959-0
06/04/2019OO-NSL-OO-NSL21-62019apr.06/04/201921-0
06/04/2019OO-NSL-OO-NSL73-62019apr.06/04/201973-0
06/04/2019OO-NSM-OO-NSM16-62019apr.06/04/201916-0
06/04/2019OO-NSM-OO-NSM18-62019apr.06/04/201936-0
06/04/2019OO-NSM-OO-NSM29-62019apr.06/04/201929-0
06/04/2019OO-NSM-OO-NSM33-62019apr.06/04/201933-0
06/04/2019OO-NSM-OO-NSM51-62019apr.06/04/201951-0
06/04/2019OO-NSQ-OO-NSQ38-62019apr.06/04/201938-0
06/04/2019OO-NSQ-OO-NSQ86-62019apr.06/04/201986-0
06/04/2019OO-NSQ-OO-NSQ91-62019apr.06/04/201991-0

Let me know if you meant something else 🙂