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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

2 questions about DATE

Hi

I have a date filed in my script in the standar form "yyyy-mm-dd"

Q1)

on my sheet I have 2 object:

listbox 1: expression =year(DATA)

listbox 2: expression =month(DATA)

When I choose an year from lisbox1, it clears the selection of month (listbox2), and when I choose a month from lisbox2, it clears the selection of year (listbox1)... so I can't select at the same time a month and a year.. why? I would like to select them at the same time!

Q2)

I have a graph where I want to compare data for the last year and the previous year, so I have 2 expression:

expression1: sum( {<DATE={"=Max(Year(DATE))"}>} measure)          WORKS

expression2: sum( {<DATE={"=Max(Year(DATE))-1"}>} measure)    DOES NOT WORK

How should I write the second expression?

Thank u very much!!

Riccardo

1 Solution

Accepted Solutions
MarcoWedel

1: create seperate fields for year and month in the load script:

LOAD

     DATA,

     year(DATA) as Year,

     month(DATA) as Month

FROM YourTable;

2: use this seperate Year filed in your set expressions:

sum( {$<Year={$(=max(Year))}>} measure)

sum( {$<Year={$(=max(Year)-1)}>} measure)


regards


Marco

View solution in original post

4 Replies
MarcoWedel

1: create seperate fields for year and month in the load script:

LOAD

     DATA,

     year(DATA) as Year,

     month(DATA) as Month

FROM YourTable;

2: use this seperate Year filed in your set expressions:

sum( {$<Year={$(=max(Year))}>} measure)

sum( {$<Year={$(=max(Year)-1)}>} measure)


regards


Marco

its_anandrjs
Champion III
Champion III

For 1st check DATA field is same for

listbox 1: expression =year(DATA)

listbox 2: expression =month(DATA)

For 2nd try like

sum( {<DATE={"=Max(Year(DATE)-1)"}>} measure)



Hope this helps

Thanks & Regards

tresesco
MVP
MVP

Very hard to answer without knowing your application. Try to create a sample app and share here.

expression2: sum( {<DATE={"=Max(Year(DATE))-1"}>} measure)    DOES NOT WORK

For this one, DATE={"=Max(Year(DATE))-1"} should probably be(if the earlier example of yours was working) :

DATE={"=Max(Year(DATE)-1)"}

simondachstr
Specialist III
Specialist III

Q1) As you're making selection in the same field the current selection will override the prior one. I recommend you to create the two different expressions directly in the script and load them as two separate fields.

Q2) Try sum( {<DATE={"$(=Max(Year(DATE))-1)"}>} measure)