Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP 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 (6)
12 Replies
Anil_Babu_Samineni

Try this?

Avg(Interval(Survey Date-Enquiry Date, 'DD')) as Days

Please add me Anil_Babu_Samineni to interact faster when reply back. Speak low think High.

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)
NemoAndStitch22
Contributor III
Contributor III
Author

I'm getting the same error of 'invalid expression' 😔

Anil_Babu_Samineni

What this is returning?

Interval(Survey Date-Enquiry Date, 'DD')

Please add me Anil_Babu_Samineni to interact faster when reply back. Speak low think High.

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)
NemoAndStitch22
Contributor III
Contributor III
Author

That bit loads in fine and is giving me the correct data. as per the photo.

 

days.jpg

sunny_talwar

Aggregate functions such as Avg, Sum, Min, Max etc need group by clause... are you using one when you do Avg()?

NemoAndStitch22
Contributor III
Contributor III
Author

Sorry, I don't understand what you mean by a clause..

In my data load I tried doing this:

 

Resident Enquiries, group by Branch

 

(All formatted correctly) which it didn't like, is that what you mean?

sunny_talwar

That is what I meant, but what all fields and expressions did you have within Load?

NemoAndStitch22
Contributor III
Contributor III
Author

snip.jpg

 

This is what I have tried, and the greyed out attempts didn't work with it like this.

sunny_talwar

Group by needs to include all the fields that are listed outside of aggregation... so, Year,  Month, MonthYear etc will all need to go into Group By or you need to remove all fields except Brand from your Load...