Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
caloyskicb
Contributor
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
william_fu
Creator II
Creator II

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
Specialist II
Specialist II

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