Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
kunkumnaveen
Specialist
Specialist

how to write expression

Hello Everyone,

can anyone help me in correcting this expression plz ,i have no clue where it is going wrong

when i use the Ceil expression(if(ceil(Day/7)>4,4,ceil(Day/7)) as Week) i am getting the values like

1

2

3

4

but what i am looking  is

Week1

Week2

Week3

Week4

that is the reason why i am  trying  this expression

Expression:

If(Day<=7, Dual('Week1', 1),

    If(Day<=14, Dual('Week2', 2),

    If(Day<=21, Dual('Week3', 3),

    If(Day<=31, Dual('Week4', 4))))) as Week

but something is missing from this expression , can suggestion plz

Untitled.pngUntitled1.png

1 Solution

Accepted Solutions
tamilarasu
Champion
Champion

Hi Naveen,

I think you missed to add Field name "Day" in first "If" statement. Try this,

Load *,
If(Day<=7, Dual('Week1', 1),
If(Day<=14, Dual('Week2', 2),
If(Day<=21, Dual('Week3', 3), Dual('Week4', 4)))) as Week,
Dual(Date(Date,'MMMM'),Month(Date(Date,'MMM'))) as Months
Resident Coal;

Drop table Coal;

View solution in original post

4 Replies
eromiyasimon
Creator II
Creator II

hi naveen,

kindly add your QVW.

kunkumnaveen
Specialist
Specialist
Author

Hi,

i cant do that bro ,

tamilarasu
Champion
Champion

Hi Naveen,

I think you missed to add Field name "Day" in first "If" statement. Try this,

Load *,
If(Day<=7, Dual('Week1', 1),
If(Day<=14, Dual('Week2', 2),
If(Day<=21, Dual('Week3', 3), Dual('Week4', 4)))) as Week,
Dual(Date(Date,'MMMM'),Month(Date(Date,'MMM'))) as Months
Resident Coal;

Drop table Coal;

kunkumnaveen
Specialist
Specialist
Author

yes ,my bad thanks for the help