Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

[set analysis] Get a value depending on a day

Hello,

I have a problem I'm the solution is simple - but I just don't get it...


My Data: I have a set of InputDates, another set of days and temperatures.
On every InputDate there are 7 temperatures of 7 days entered. The range is InputDate-1 to InputDate+6.

I'm working in a pivot diagram. My dimension is Day.

So it looks something like that:

InputDateDayTemperatur
01.10.201430.09.201416.5
01.10.201401.10.201415.1
01.10.201402.10.201415.7
01.10.201403.10.201415.9
01.10.201404.10.201415.1
01.10.201405.10.201415.9
01.10.201406.10.201414.3

02.10.2014

01.10.201415.6
02.10.201402.10.201416.1
02.10.201403.10.201415.6
02.10.201404.10.201415.5
02.10.201405.10.201412.2
02.10.201406.10.201411.4
02.10.201407.10.201413.2
03.10.201402.10.201414.3
03.10.201403.10.201416.2
03.10.201404.10.201412.4
03.10.201405.10.201416.4
03.10.201406.10.201414.9
03.10.201407.10.201418.1
03.10.201408.10.201415.3

Now I want to display the average temperature over all InputDays for one Day. I.e.: 03.10.2014 (15.9 + 15.6 + 16.2)/3 = 15.9

I have following approach:

=(Sum({$<InputDate={$(=Date(Day))}>}temperature)+Sum({$<InputDate={$(=Date(Day-1))}>}temperature)+Sum({$<InputDate={$(=Date(Day-2))}>}temperature))/3

But nothing is displayed...

1 Solution

Accepted Solutions
sasiparupudi1
Master III
Master III

Hi

Your expression should be

(Sum({$<InputDate={"$(=date#(Day,'DD.MM.YYYY'))"}>} temperature )+Sum({$<InputDate={"$(=date(date#(Day,'DD.MM.YYYY')-1,'DD.MM.YYYY'))"}>} temperature )+Sum({$<InputDate={"$(=date(date#(Day,'DD.MM.YYYY')-2,'DD.MM.YYYY'))"}>} temperature ))/3

Please see the attachement. Hope this helps

View solution in original post

8 Replies
Not applicable
Author

I almost forgot: If I replace the $(=Date(Day)) with the actual term "03.10.2014" it works...

sasiparupudi1
Master III
Master III

Please try

day(date#('04.10.2014','DD.MM.YYYY'))

antoniotiman
Master III
Master III

Hi Markus,

Try (e.g. in Pivot Table)

Dimensions : Day,InputDate

Expression

RangeAvg(Top(Temperatur,1,NoOfRows()))

Regards,

Antonio

Not applicable
Author

Hi Sasidhar,

thanks for the answer - but I don't want a fix date in the expression, the variable Day should be used.

Not applicable
Author

Hi Antonio,

your solution works, but I'm not quite happy with the layout. Now I have the additional InputDate dimension and therefore the right answer several times (for each InputDate). How can I extract the InputDate from the dimension into the expression layer?

Thanks for the help!

Regards

Markus

antoniotiman
Master III
Master III

If You Remove InputDate,

expression is

Avg(Temperatur)

sasiparupudi1
Master III
Master III

Replace the date string with your day variable and it should work fine

hth

sasiparupudi1
Master III
Master III

Hi

Your expression should be

(Sum({$<InputDate={"$(=date#(Day,'DD.MM.YYYY'))"}>} temperature )+Sum({$<InputDate={"$(=date(date#(Day,'DD.MM.YYYY')-1,'DD.MM.YYYY'))"}>} temperature )+Sum({$<InputDate={"$(=date(date#(Day,'DD.MM.YYYY')-2,'DD.MM.YYYY'))"}>} temperature ))/3

Please see the attachement. Hope this helps