Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

caloyskicb
New Contributor

Age calculation

Hello

Need help calculating average age using this expression:

Average(Age (service_date, entry date) where

Service Name = "Service" and Entry Provider = "Provider1"

2 Replies
williamfuu
Contributor II

Re: Age calculation

Is age the difference between service_date and entry_date?

Try creating a Age field in your load script (something like (service_date - entry_date) AS Age

Then use the Age field in your average:

Avg({$<ServiceName={'Service'}, EntryProvider={'Provider1'}>} Age)

dwforest
Valued Contributor

Re: Age calculation

the age function only returns years.

As William said, you could put the difference as a new field, but you can also just do it in an expression:

Avg({$<ServiceName={'Service'}, EntryProvider={'Provider1'}>} service_date - entry_date)


If you are looking to group the average by Service and Provider, then you'd need to use Aggr()

Avg(Aggr(Avg(service_date - entry_date),ServiceName,EntryProvider))

Community Browser