Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Can someone help me to do the script for the query below??

Hi,

Can someone help me to script the query below?

I have 3 fields to use for this script.

1. Document Number

2. Approved Date

3. Release Date

Query: I wanted to get the month created (this could be approved date or release date). The problem is some of the rows of approved date are blanks. I wanted to get the released date insted for those blanks in approved date. How to do this script? Im not sure if if else statement would be fit for this.

Thank you..

1 Solution

Accepted Solutions
CELAMBARASAN
Partner - Champion
Partner - Champion

Try like this

LOAD

     DocumentNumber,

     Month(If(Len(ApprovedDate) > 0, ApprovedDate, ReleaseDate)) AS Month

//  if it is really date field, try  Month(Alt(ApprovedDate, ReleaseDate)) AS Month

FROM DataSource

View solution in original post

8 Replies
whiteline
Master II
Master II

LOAD

     [Document Number],

     if(not isnull([Approved Date]), Month([Approved Date]), Month([Release Date])) as [Release Month]

FROM ...

CELAMBARASAN
Partner - Champion
Partner - Champion

Try like this

LOAD

     DocumentNumber,

     Month(If(Len(ApprovedDate) > 0, ApprovedDate, ReleaseDate)) AS Month

//  if it is really date field, try  Month(Alt(ApprovedDate, ReleaseDate)) AS Month

FROM DataSource

Anonymous
Not applicable
Author

The Alt() function is the best solution to your problem as it replaces any null values with the field in your first argument with your specified second argument.

Not applicable
Author

Try like below:

LOAD [Document Number] ,

          Month( ALT(Release_date,Approved_date)) AS Released_Month

FROM ,,,,;

Not applicable
Author

Hi,

It worked! Helped a lot

Thank you!!

Not applicable
Author

Hi Whiteline,

Thanks for this script. It helped too

Not applicable
Author

Yes, is used Alt and worked. Thanks!

Not applicable
Author

Thank you!