Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Daryn
Creator
Creator

AGGR (of days - between two date fields) against another field - but want to restrict to a rolling period (ie 12 months)

Hi,

I am using (correctly or incorrectly)...

=avg(aggr(([Date Out])-([Date In]), [Batch]))

 

To get the average amount of days an item is onsite.

This reports okay, but I want to restrict it to perhaps a rolling 12 month period (or less).

I tried:

=avg(aggr(( ( [Date Out.autoCalendar.Date] >= (Addmonths ( Today (),-12)))- [Date In.autoCalendar.Date] >= (Addmonths ( Today (),-12))), [Batch]))

But that didn't appear to work correctly. My date is formatted as DD.MM.YYYY

Any help appreciated, 

Regards Daryn

 

Labels (1)
1 Solution

Accepted Solutions
Daryn
Creator
Creator
Author

Solved it I think with:

avg(aggr(if([Date In.autoCalendar.Date] >= addyears(max([Date In.autoCalendar.Date]), -1), ([Date Out] - [Date In]), null), [Batch]))

View solution in original post

1 Reply
Daryn
Creator
Creator
Author

Solved it I think with:

avg(aggr(if([Date In.autoCalendar.Date] >= addyears(max([Date In.autoCalendar.Date]), -1), ([Date Out] - [Date In]), null), [Batch]))