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

If statement

Good Afternoon,

I'm wondering if anyone can help me with this.  I need to include an if statement that says if Month equals 1 then Month equals 13 and Year equals -1.

The reason for this is that headcount is pulled on the first day of the month for the previous month headcount.  For example, January 1st headcount number is the headcount number for December of the previous year.  I already have Month-1 to take care of all the other months.  The tricky part is always going to be January 1st.

12 Replies
vishsaggi
Champion III
Champion III

Can you tell us your expected ouput and relevant fields you are using or share a sample app to quickly work on.?

fanninam
Creator
Creator
Author

This is the script.  It is simple and pulling in monthly CSV files only.  The only problem I have is the CSV file for January 1st every year is Month 1.  Therefore, Month-1 makes it zero instead of making it Month 12..... of course the Year would need to be -1 as well.  Any suggestions?

HPU:
LOAD [EMP FILE],
LASTNAME,
FIRSTNAME,
Company,
COMPANYCODE,
Division,
DEPT,
TITLE,
Status,
EjFTE,
[Business Unit Descrip],
TERMDATE,
STARTDATE,
SUPV,
text(Date(Date#(Month-1,'MM'),'MMM')) as MonthName,
Month,
Year,
ApplyMap('DeptGroups',[Business Unit Descrip], Null()) AS [Dept Groups],
ApplyMap('DeptGroups2',[Business Unit Descrip], Null()) AS Owner,
ApplyMap('DeptGroups3',[Business Unit Descrip], Null()) AS Area
FROM
[\\ftwqlikt001\Qlikview_Dev\External Data\Human Resources\HCUpload_*.csv]
(
txt, codepage is 1252, embedded labels, delimiter is ',', msq);

vishsaggi
Champion III
Champion III

What happens when you do this?

text(Date(Date#(Month-13,'MM'),'MMM')) as MonthName,

fanninam
Creator
Creator
Author

When I use

text(Date(Date#(Month-13,'MM'),'MMM')) as MonthName,

there is no change to Month but it causes MonthName not to populate with data.

vishsaggi
Champion III
Champion III

Can you share a sample app and expected output as a screen shot ? Would help us to quickly figure out and work on?

You can scramble your data like here:

Preparing examples for Upload - Reduction and Data Scrambling

fanninam
Creator
Creator
Author

How do I share an app?

vishsaggi
Champion III
Champion III

Click on reply and you can see Here:

Capture.PNG

Once you click on Advance editor you will have an attach icon in the bottom right.

fanninam
Creator
Creator
Author

I don't see "Use advanced editor" 

Capture.PNG

vishsaggi
Champion III
Champion III

Can you click on reply to your original query and still you don't see? Did you login to Qlik account?