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: 
kunkumnaveen
Specialist
Specialist

how to get week

HI All,

i am trying to put days under particular weeks,which is not working .

if(Day='1,2,3,4,5,6,7','Week1',if(Day='8,9,10,11,12,13,14','Week2',if(Day='15,16,17,18,19,20,21','Week3',if(Day='22,23,24,25,26,27,28,29,30,31','Week4')))) as Week

can any one suggestion where it went wrong

qt1:

Load*,

Dual(Date(Date,'MMMM') ,Month(Date(Date,'MMM'))) as Month,

day(Date) as Day,

//'Week' & Week(Date) as Week;

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

          quantity

FROM

(ooxml, embedded labels, table is Sheet1);

load Day,

if(Day='1,2,3,4,5,6,7','Week1',if(Day='8,9,10,11,12,13,14','Week2',if(Day='15,16,17,18,19,20,21','Week3',if(Day='22,23,24,25,26,27,28,29,30,31','Week4')))) as Week

Resident qt1;

1 Solution

Accepted Solutions
lironbaram
Partner - Master III
Partner - Master III

hi

in this case , change the function to :

load Day,

if(ceil(Day/7)>4,4,ceil(Day/7)) as Week ///this will create your week number in much more efficient way

Resident qt1;

View solution in original post

8 Replies
lironbaram
Partner - Master III
Partner - Master III

hi

your if statement is wrong

here is another version that should work

qt1:

Load*,

Dual(Date(Date,'MMMM') ,Month(Date(Date,'MMM'))) as Month,

day(Date) as Day,

//'Week' & Week(Date) as Week;

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

          quantity

FROM

(ooxml, embedded labels, table is Sheet1);

load Day,

ceil(Day/7) as Week ///this will create your week number in much more efficient way

Resident qt1;

kunkumnaveen
Specialist
Specialist
Author

HI

if i use ceil function it coming out 5 weeks in a month,but i need only 4 weeks for all the months

kunkumnaveen
Specialist
Specialist
Author

Even this is not working ,i am getting   ')' missing  error but everything looks ok

if(Day <=7,'Week1',  if(Day >7<=14 ,'Week2', if(Day >14<=21,'Week3', if(Day >21<=31,'Week4')))) as Weeks

lironbaram
Partner - Master III
Partner - Master III

hi

in this case , change the function to :

load Day,

if(ceil(Day/7)>4,4,ceil(Day/7)) as Week ///this will create your week number in much more efficient way

Resident qt1;

kunkumnaveen
Specialist
Specialist
Author

perfect man,thanks very munch...it worked

kunkumnaveen
Specialist
Specialist
Author

can u plz explain me wat exactly this is doing ..plz

if(ceil(Day/7)>4,4,ceil(Day/7)) as Week

vinieme12
Champion III
Champion III

You should read this post and it has links to other week manipulation posts embedded

Recipe for a 4-4-5 Calendar

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
MarcoWedel

Hi,

also possible:

RangeMin(Ceil(Day/7),4) as Week

hope this helps

regards

Marco