Qlik Community

Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

Announcements
Qlik Analytics Tour 2020 Online. Begins August 10th. Register Today
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
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

12 Replies
Highlighted

Try this?

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

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)
Highlighted
Contributor III
Contributor III

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

Highlighted

What this is returning?

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

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)
Highlighted
Contributor III
Contributor III

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

 

days.jpg

Highlighted

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

Highlighted
Contributor III
Contributor III

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?

Highlighted

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

Highlighted
Contributor III
Contributor III

snip.jpg

 

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

Highlighted

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...