Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

marksmunich
Contributor II

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
Honored Contributor II

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

check if QV regards enddate and startdate as date fields

marksmunich
Contributor II

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

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

giakoum
Honored Contributor II

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

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

marksmunich
Contributor II

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

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
Honored Contributor II

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

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.

Employee
Employee

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

Here is a simple sample:

AVERAGE.PNG.png

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

Hi,

I am little confuse can you just tell us.

What is your expected output??

Regards

Regards,
Prashant Sangle
Not applicable

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

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

marksmunich
Contributor II

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

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.

Community Browser