Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
kdmarkee
Specialist
Specialist

Create a static average based on all values of a field in a data model

I would like to create a static average based on all values of a field in a data model, and it is static because it would ignore selections.  I can't seem to get it to work in my expression.  Below is what I'm looking for.  Basically, regardless of what ID, ACCOUNT, etc I may filter on, I want my Avg Age by Plan field to always remain the avg based on all rows of data in my data model per plan.  Imagine the top chart as the full data model, and the bottom chart is the result if I select ACCOUNT 5522 only.  Thanks.

static avg based on one field in model.GIF

Labels (1)
1 Solution

Accepted Solutions
Kushal_Chawda

@kdmarkee  try below

=sum(total <PLAN>aggr(Avg({<ID, ACCOUNT,[First Payment Date]>}[First Paymt Age]),PLAN)*avg(1)

 

View solution in original post

4 Replies
sunny_talwar

@kdmarkee May be this

Avg(TOTAL {1} [First Paymt Age])

or this if First Paymt Age is an expression

Avg(TOTAL {1} Aggr(Sum({1} [First Paymt Age]), ID, ACCOUNT, PLAN, [First Payment Date]))
kdmarkee
Specialist
Specialist
Author

I should clarify that I have several plans in my data model, so I think there is an additional piece of code needed in the/your set analysis...a grouping on PLAN somehow.  I could do this in script, but wanted to know if it was possible in an expression itself.

 

sunny_talwar

@kdmarkee not sure I follow

Kushal_Chawda

@kdmarkee  try below

=sum(total <PLAN>aggr(Avg({<ID, ACCOUNT,[First Payment Date]>}[First Paymt Age]),PLAN)*avg(1)