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: 
Not applicable

Sum with Max Function throwing Error

Hi All,

I am stuck with an expression:

My reqmnt:

I calculated the datediff between two dates for an user: Interval(Max(RespondTime)-JoinDt,'d')

I want to calculate the average date diff for all users:

When i try something like this its throwing an error:

sum( Interval(Max(RespondTime)-JoinDt,'d'))/Count(UserId)

Any help??

1 Solution

Accepted Solutions
Jason_Michaelides
Luminary Alumni
Luminary Alumni

And put it in a text object rather than a chart.  Oh, and you can wrap it in Interval() I think to get it formatted in minutes:

Interval(Avg(Aggr((Max(RespondTime)-JoinDt),UserID)))

Hope this helps,

Jason

View solution in original post

8 Replies
Jason_Michaelides
Luminary Alumni
Luminary Alumni

Interval() is just a formatting function, I believe.  Also, the expression you need will vary depending if it is in a chart or not and what the dimensions are.

What exactly are you trying to achieve?

Not applicable
Author

interval() function i believe it calculates the datediff between two dates.

and i am using the above expression in a chart(table) with no dimensions)

Jason_Michaelides
Luminary Alumni
Luminary Alumni

No dimensions?  So you just want a single number returned that is the average of Max(RespondTime)-JoinDt, across all users? Max(RespondTime) is no the global Max() but a per-user Max()?

I this is your requirement then you will need to use Aggr().

Is this what you want to achieve?

jagan
Luminary Alumni
Luminary Alumni

Hi,

I think JoinDt is a dimension and having multiple values.  If so, try getting the single value by using max() or min().  That's why you are getting an error.

If possible attach a sample file.

Regards,

Jagan.

Not applicable
Author

Exactly Jason.

Can you please send me the expression with Aggr fucntion.I tried but its not wrkn.

Jason_Michaelides
Luminary Alumni
Luminary Alumni

Try this:

Avg(Aggr((Max(RespondTime)-JoinDt),UserID))

Jason_Michaelides
Luminary Alumni
Luminary Alumni

And put it in a text object rather than a chart.  Oh, and you can wrap it in Interval() I think to get it formatted in minutes:

Interval(Avg(Aggr((Max(RespondTime)-JoinDt),UserID)))

Hope this helps,

Jason

Not applicable
Author

Thanks Jason !! It worked!!