Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

adamgaleza
New Contributor

SQL script dunno how to write in QlikSense need help.

Hi Everyone,

Im new employee in QLIK in my company.

I hav problems about Two script lines from my example sql procedure:

         ,ISNULL(B.[Dimension Value Code],ISNULL(F.REGIONKL,'')) REG_DIM

       ,IIF(ISNULL(C.DOSTAWA_KRAJ,'')='',ISNULL(G.Country,''),C.DOSTAWA_KRAJ) DOSTAWA_KRAJ



I try to write code at Qlik as :


    

IF(IsNull("Dimension Value Code"),IF(ISNULL(REGIONKL),'',REGIONKL),"Dimension Value Code") as REG_DIM,

    IF(IsNull(DOSTAWA_KRAJ) or DOSTAWA_KRAJ='',IF(ISNULL(Country),'',Country),DOSTAWA_KRAJ) as DOSTAWA_KRAJ,

But My records don't have at all that same values like i will exec full script from SQL.


This is only small section from this code. Whole procedure is much more big, but i didnt saw more operations on this values.

Why i hav problems. That same "company name" from one table hav additional region and country in record, but for other record isn't.

1 Solution

Accepted Solutions
kvanandan1
Contributor

Re: SQL script dunno how to write in QlikSense need help.

Hi,

Please use the below script in QlikSense to check the null value with len function.

if(len([Dimension Value Code])=0,if(len(REGIONKL)=0,'',[REGIONKL]),[Dimension Value Code])  as REG_DIM

,

if(len([DOSTAWA_KRAJ])=0,if(len(Country)=0,'',[Country]),[DOSTAWA_KRAJ])  as DOSTAWA_KRAJ

4 Replies
dwforest
Valued Contributor

Re: SQL script dunno how to write in QlikSense need help.

why not just use SQL as is in your script...

adamgaleza
New Contributor

Re: SQL script dunno how to write in QlikSense need help.

Becouse i wanna know how to write this as Qlik code, not SQL

kvanandan1
Contributor

Re: SQL script dunno how to write in QlikSense need help.

Hi,

Please use the below script in QlikSense to check the null value with len function.

if(len([Dimension Value Code])=0,if(len(REGIONKL)=0,'',[REGIONKL]),[Dimension Value Code])  as REG_DIM

,

if(len([DOSTAWA_KRAJ])=0,if(len(Country)=0,'',[Country]),[DOSTAWA_KRAJ])  as DOSTAWA_KRAJ

dwforest
Valued Contributor

Re: SQL script dunno how to write in QlikSense need help.

There doesn't seem to be anything wrong with the "translation", so it may have something to do with the rest of the SQL.

Complete code is always preferable and sample data.

Sometimes the issue is not where we think.

Personally, i use SQL or Qlik code based on what is easier to write/understand and prefer as much be done by the database as possible...

Community Browser