Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
marksmunich
Creator III
Creator III

how to perform a max min differene and store it in a new field


I am calculating Min of start date and max of enddate and want to store the result in a field.

eg: max(enddate)-min(Startdate) as Result_date.

but ist returning the error.

my ultimate Goal is to calculate the average(Result_date) for several product categories.

Thanks

9 Replies
giakoum
Partner - Master II
Partner - Master II

check if QV regards enddate and startdate as date fields

marksmunich
Creator III
Creator III
Author

they are number fields, but ultimately i Need result in date Format or days

giakoum
Partner - Master II
Partner - Master II

then it should work. Do you have a sample app?

marksmunich
Creator III
Creator III
Author

This is my requirement

max(enddate)-min(Startdate) as Result_date

and AVG(Result_Date)

avg(max(enddate)-min(Startdate)) as Résult date

does it work or do you have any suggestions.

giakoum
Partner - Master II
Partner - Master II

If you max(enddate)-min(Startdate) the result is not a date, it is a number showing the number of days between the startdate and enddate (provided that QV treats startdate and enddate as dates). Is that what you want to average? In any case, a sample app would help.

JonnyPoole
Employee
Employee

Here is a simple sample:

AVERAGE.PNG.png

PrashantSangle

Hi,

I am little confuse can you just tell us.

What is your expected output??

Regards

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
Not applicable

Firstly, are you doing this calculation in Script? If yes, use the Group By functions

marksmunich
Creator III
Creator III
Author

I tried doing in the script, but it is failing. for example first i want to find the Result time which is Max (Startdate) - Min(Enddate)

which i want to store in the  new field result field, but qv says Expression error.

second Thing is i want to find the average result for each product per day. avg(Resultday)

The first one I have achieved in the frontend using a TextBox, but the second one I am unable to get it.