Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

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

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

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

8 Replies
whiteline
Honored Contributor II

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

LOAD

     [Document Number],

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

FROM ...

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

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

michael_gardner
Contributor III

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

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

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

Try like below:

LOAD [Document Number] ,

          Month( ALT(Release_date,Approved_date)) AS Released_Month

FROM ,,,,;

Not applicable

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

Hi,

It worked! Helped a lot

Thank you!!

Not applicable

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

Hi Whiteline,

Thanks for this script. It helped too

Not applicable

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

Yes, is used Alt and worked. Thanks!

Not applicable

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

Thank you!

Community Browser