Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to get day and month from date

Hi all,

i have a table like this

Dayvalues
2012/01/012
2012/06/013
2013/01/017
2013/06/014

if a select 2012/01/01 from a combo box i need that in a graph wiil be only the values where day and month are equals(in this case 2 and 7)

tyvm

Simone

1 Solution

Accepted Solutions
jagan
Luminary Alumni
Luminary Alumni

Hi Simone,

You should use only Dimensions in the Set Analysis expression, so you use the following script and reload

Data:

LOAD *,

          Month(Day) as Month,

          Day(Day) as Day;

LOAD

     date#(Day,'YYYY/MM/DD') as Day,

     values

FROM DataSource

Now you will two new dimensions Month and Day.

Sum({<Month={1}, Day ={31}>} Measure)

or

Sum({<Month={'Jan'}, Day ={31}>} Measure)

Hope this helps you.

Regards,

Jagan.

View solution in original post

12 Replies
swuehl
MVP
MVP

Maybe create two additional fields in your table containing day (or the master calendar):

LOAD *,

          Month(Day) as Month,

          Day(Day) as DayOfMonth;

LOAD

     date#(Day,'YYYY/MM/DD') as Day,

     values

FROM ...;

Then in your chart, use something like

=sum({<Month = p(), DayOfMonth = p(), Day= >} values)

salto
Specialist II
Specialist II

Hi,

You need to extract Month and Day Number from "Day" field:

1 .- num(Month(DayField)) -> 11 for 26/11/2013

2.-  num(Day(DayField)) -> 26 for  26/11/2013

Then build your graph expressions with set analysis taking into account only Month and Day, and disregarding all other selections.

Hth.

VishalWaghole
Specialist II
Specialist II

Hi simone,

Try this,

LOAD Month(Day) as CalenderMonth,

          Day(Day) as CalenderDay

FROM TableName;

Thanks and Regards,

Vishal Waghole

Not applicable
Author

hi salto,

i extracted the value of day and month from field "Day" but i didn't understand how to pass it in expression

tyvm

MayilVahanan

Hi

Try like this

PFA

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
jagan
Luminary Alumni
Luminary Alumni

Hi,

Just select Day and Month in list box and don't select year, qlikview automatically filters the remaining rows.  You don't need to pass this in expression.  You just use this script and expression

Data:

LOAD *,

          Month(Day) as Month,

          Day(Day) as DayOfMonth;

LOAD

     date#(Day,'YYYY/MM/DD') as Day,

     values

FROM ...;

=Sum(Measure)

If you want to explicitly mention in expression without selection then use like this

Sum({<Month={1}, Day ={1}>} Measure)

or

Sum({<Month={'Jan'}, Day ={1}>} Measure)

Hope this helps you.

Regards,

Jagan.

Not applicable
Author

i  this expression in expression tab

=Sum({<Day(fieldDay)={31},Month(fieldDay)={1}>} Values)

but it doesn't work, there is a error

I'm very close to solution!!!!

tyvm

Simone

swuehl
MVP
MVP

You can only use field names on the left side of a field modifier, not functions.

Have you tried what I suggested above?

jagan
Luminary Alumni
Luminary Alumni

Hi Simone,

You should use only Dimensions in the Set Analysis expression, so you use the following script and reload

Data:

LOAD *,

          Month(Day) as Month,

          Day(Day) as Day;

LOAD

     date#(Day,'YYYY/MM/DD') as Day,

     values

FROM DataSource

Now you will two new dimensions Month and Day.

Sum({<Month={1}, Day ={31}>} Measure)

or

Sum({<Month={'Jan'}, Day ={31}>} Measure)

Hope this helps you.

Regards,

Jagan.