Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Need help in If statement in the Load Script

Hello Friends,

In the Load statement, I am trying to list the name of the months using my data but its showing only one month(Sep 2012) as Monthname.

Can anybody tell where I am making a mistake.

If([MONTH 01], Monthname(Today()-1),

                                             If([MONTH 02], Monthname(Today()-2),

                                                                 If([MONTH 03], Monthname(Today()-3)))) as MonthName

Regards

Chriss

5 Replies
whiteline
Master II
Master II

Instead subtractacting days Monthname(Today()-1)

You should subtract months: Monthname(Today())-1

Not applicable
Author

Hello Whiteline,

I tried what you said, but date format is coming like (31/08/2012).

Regards

Chriss

whiteline
Master II
Master II

Sorry, Monthname actualy also returns full date (confused it with month()).

you should try AddMonths(Today(),-1).

Then if you want to change  date format just use date() function.

gandalfgray
Specialist II
Specialist II

Hi

try the AddMonths function:

If([MONTH 01], Monthname(AddMonths(Today(),1),

                                             If([MONTH 02], Monthname(AddMonths(Today(),2),

                                                                 If([MONTH 03], AddMonths(Monthname(Today(),-3)))) as MonthName

jonathandienst
Partner - Champion III
Partner - Champion III

Hi

Assuming [Month 01] a flag value (ie values 0 or 1 or true() or false()? If so:

If ([MONTH 01], MonthName(AddMonths(Today(), -1)),

If ([MONTH 02], MonthName(AddMonths(Today(), -2))...)).

Regards

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein