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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
NemoAndStitch22
Contributor III
Contributor III

Avg function

Hiya,

 

I'm creating a script and want to do the average days between enquiry and survey.

 

I've loaded in my data and created the metric of (Survey Date-Enquiry Date) as Days between survey and Enquiry

I've then noconcatenated this and loaded it again as a proper field.

Then tried to do

 

Avg(Days between Enquiry and Survey) as Avg Days.

When I load this in it kicks up a fuss. 

 

Does anyone know what I'm doing wrong?

 

Thanks

Labels (2)
12 Replies
NemoAndStitch22
Contributor III
Contributor III
Author

It doesn't like that...The previously shared script before adding the group by was fine, and now it's not...

 

Annotation 2019-11-19 140547.jpg11.jpg

Anil_Babu_Samineni

Try to share full script of yours that shows Avg and Group By if u r trying in script?

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
NemoAndStitch22
Contributor III
Contributor III
Author

Here  you go:

 

Enquiries:
LOAD

Date#(subfield(FileBaseName(),' ',7),'YYYY') as Year,
Date#(subfield(FileBaseName(),' ',6),'MMM') as Month,
Date#(subfield(FileBaseName(),' ',6)&' '&subfield(FileBaseName(),' ',7),'MMM YYYY') as MonthYear,

No.,
Description,
"Description 2",
Status,
"Last Amended",
"Global Dimension 1 Code" as "Branch",
"Enquiry Owner",
Surveyor,
"Enquiry Date",
"Survey Appointment",
"Survey Enquiry Status",
"Loss Reason Comment",
"Call Code",
"Symptom 1",
"Symptom 2",
"Symptom 3",
"Symptom 4",
("Survey Appointment"-"Enquiry Date") as "Days between Enquiry and Survey"

 


FROM [lib://Enquiry Extract/Enquiry Extract*.xlsx]
(ooxml, embedded labels, table is [Book 1]) where not "Survey Appointment" like '';



NoConcatenate
Enquiries2:
LOAD

Year,
Month,
MonthYear,
No.,
Description,
"Description 2",
Status,
"Last Amended",
"Branch",
"Enquiry Owner",
Surveyor,
"Enquiry Date",
"Survey Appointment",
"Survey Enquiry Status",
"Loss Reason Comment",
"Call Code",
"Symptom 1",
"Symptom 2",
"Symptom 3",
"Symptom 4",
"Days between Enquiry and Survey",
Interval("Survey Appointment"-"Enquiry Date", 'DD') as Days


//Avg("Days between Enquiry and Survey") as "Avg Days"
//if("Days between Enquiry and Survey"='>0',(Avg("Days between Enquiry and Survey")),'0') as "Average Days"
// avg("Days between Enquiry and Survey") as days

Resident Enquiries Group By Year,
Month,
MonthYear,
No.,
Description,
"Description 2",
Status,
"Last Amended",
"Branch",
"Enquiry Owner",
Surveyor,
"Enquiry Date",
"Survey Appointment",
"Survey Enquiry Status",
"Loss Reason Comment",
"Call Code",
"Symptom 1",
"Symptom 2",
"Symptom 3",
"Symptom 4",
"Days between Enquiry and Survey" ;

drop table Enquiries