Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements

Breathe easy -- you now have more time to plan your next steps with Qlik!
QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.

Not applicable

Qlikview SQL Load IF date is filled

Hi All,

Im having a problem with something and trying to solve it for like 2 days now, without anny solutions.

What i want to create is an extra field which is filled with the date field from table VDO (if they are filled), if not i want to use the dates from Table2 (Or table1 if its easier, because they are equal).

I couldnt solve this problem because i wasn't able to use fields from other tables at once. Like use date-year from Table1 and Per-date1 from VDO at the same time.

I have this (3) tables:

TABLE1:

LOAD *,

ID & '_' & date-year & '_' & [date-month] as Key;

SQL SELECT ID,

  date-year,

  date-month

  Amount-eur,

FROM Table1;

TABLE2:

LOAD *,

  yID & '_' & yDateYear & '_' & yDateMonth as Key;

SQL SELECT yID,

  date-year as yDateYear,

  date-month as yDateMonth,

  ID_VDO

FROM Table2;

LOAD *,

  Year([Per-date1]) as VdoYear,

  Month([Per-date1]) as VdoMonth;

SQL SELECT ID_VDO,

  Per-date1,

FROM VDO;

1 Solution

Accepted Solutions

Re: Qlikview SQL Load IF date is filled

Try this.

  Load *,if(isnull(Per-date1) or Per-date1='',date-year, Per-date1) as New_Date ;

    SELECT a.yID,

  a.date-year as yDateYear,

  a.date-month as yDateMonth,

  a.ID_VDO,

  b.Per-date1

     From Tabl2 a, VDO b

     where a.ID_VDO = b.ID_VDO

Regards,

Kaushik Solanki

4 Replies

Re: Qlikview SQL Load IF date is filled

Hi,

     Try like this.

     Load *;

    SELECT a.yID,

  a.date-year as yDateYear,

  a.date-month as yDateMonth,

  a.ID_VDO,

  b.Per-date1

     From Tabl2 a, VDO b

     where a.ID_VDO = b.ID_VDO

Regards,

Kaushik Solanki

Not applicable

Re: Qlikview SQL Load IF date is filled

I succesfully connected the tables.

The thing i want is:

If date from VDO is filled then take it, if not use the date from Table2.

Kind regards,

Triglobal

Re: Qlikview SQL Load IF date is filled

Try this.

  Load *,if(isnull(Per-date1) or Per-date1='',date-year, Per-date1) as New_Date ;

    SELECT a.yID,

  a.date-year as yDateYear,

  a.date-month as yDateMonth,

  a.ID_VDO,

  b.Per-date1

     From Tabl2 a, VDO b

     where a.ID_VDO = b.ID_VDO

Regards,

Kaushik Solanki

Not applicable

Re: Qlikview SQL Load IF date is filled

I've got it quite working as i wanted.

The only problem right now is that I lose the results from table VDO that don't have a ID_VDO filled.

Do you have anny solution for this?

Thanks so much!!