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

Announcements
Posting on Qlik Community is temporarily paused for some users. Thank you for patience and we'll update you soon!
cancel
Showing results for 
Search instead for 
Did you mean: 
fmazzarelli
Partner - Creator III
Partner - Creator III

YEAR / months

Hi,

i would create a variable dividing the year in 2 - 3 - 4 - 5 months.

a field "data" is colled DATE_ORD - YYYY/MM/GG

How could I do?

2 months:

gen - feb

mar - apr

mag - giu

lug - ago

set - ott

nov - dic

3 months:

gen - feb - mar

apr - mag - giu

lug - ago -set

ott - nov - dic

4 month

gen - feb - mar - apr

mag - giu  lug - ago

set - ott - nov - dic

6 months
gen - feb - mar - apr - mag - giu

lug - ago - set - ott - nov - dic

Labels (1)
20 Replies
swuehl
Champion III
Champion III

Something like

LOAD *,

        Ceil( Month(DATE_ORD) / 2 ) As TwoMonthPeriod,

        Ceil( Month(DATE_ORD) / 3 ) As ThreeMonthPeriod,

        Ceil( Month(DATE_ORD) / 4 ) As FourMonthPeriod,

        Ceil( Month(DATE_ORD) / 6 ) As SixMonthPeriod;

LOAD Date#(DATE_ORD,'YYYY/MM/DD') as DATE_ORD

FROM YourTableSource;

fmazzarelli
Partner - Creator III
Partner - Creator III
Author

looking your code should be fine

I'm using it during reload data function. Is it correct?

Because "the command Ceil is a value unrecognized.

fmazzarelli
Partner - Creator III
Partner - Creator III
Author

ah, i'm using an sql table

swuehl
Champion III
Champion III

Is that the error you get when reloading?

ceil() is a numeric function and should work in a QV LOAD statement. Could you post your script or document log?

fmazzarelli
Partner - Creator III
Partner - Creator III
Author

select

campo1

,campo2

,campo3

from nomedatabase.[dbo].[nometabella]

swuehl
Champion III
Champion III

You need to use the QV functions in a preceding LOAD statement:

LOAD *,

        Ceil( Month(DATE_ORD) / 2 ) As TwoMonthPeriod,

        Ceil( Month(DATE_ORD) / 3 ) As ThreeMonthPeriod,

        Ceil( Month(DATE_ORD) / 4 ) As FourMonthPeriod,

        Ceil( Month(DATE_ORD) / 6 ) As SixMonthPeriod;

LOAD Date#(DATE_ORD,'YYYY/MM/DD') as DATE_ORD;

SQL SELECT ....

FROM YourTableSource;

fmazzarelli
Partner - Creator III
Partner - Creator III
Author

hi,

but the field DATE_ORD is extracted by a select (sql).

I tried to put them after but, i receive a syntax error (FROM is missing

SQL SELECT

[DATE_ORD]

FROM [DATABASE].[dbo].

;

LOAD *,

        Ceil( Month(DATE_ORD) / 2 ) As TwoMonthPeriod,

        Ceil( Month(DATE_ORD) / 3 ) As ThreeMonthPeriod,

        Ceil( Month(DATE_ORD) / 4 ) As FourMonthPeriod,

        Ceil( Month(DATE_ORD) / 6 ) As SixMonthPeriod;

LOAD Date#(DATE_ORD,'YYYY/MM/DD') as DATE_ORD;

swuehl
Champion III
Champion III

That's why a called it a preceding LOAD statement:

LOAD *,

        Ceil( Month(DATE_ORD) / 2 ) As TwoMonthPeriod,

        Ceil( Month(DATE_ORD) / 3 ) As ThreeMonthPeriod,

        Ceil( Month(DATE_ORD) / 4 ) As FourMonthPeriod,

        Ceil( Month(DATE_ORD) / 6 ) As SixMonthPeriod;

LOAD Date#(DATE_ORD,'YYYY/MM/DD') as DATE_ORD;

SQL SELECT

[DATE_ORD]

FROM [DATABASE].[dbo].

;

fmazzarelli
Partner - Creator III
Partner - Creator III
Author

OK

It works