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

urgent pls............sql case to qlikview

Hi experts,

I need to use this sql expression in qlikview load script.

Expression =COUNT(DISTINCT CASE WHEN ORDTYPE='SL' THEN ISNULL(SLS.IVNO,'') END) AS IVCOUNT

How can i do this.

Please help in this regard

1 Solution

Accepted Solutions
Gysbert_Wassenaar

Count(distinct If(ORDTYPE='SL', IsNull(SLS.IVNO))) AS IVCOUNT


talk is cheap, supply exceeds demand

View solution in original post

9 Replies
Gysbert_Wassenaar

Count(distinct If(ORDTYPE='SL', IsNull(SLS.IVNO))) AS IVCOUNT


talk is cheap, supply exceeds demand
jonathandienst
Partner - Champion III
Partner - Champion III

ISNULL in SQl works differently to ISNULL in QV. I think this might be more accurate:

=COUNT(DISTINCT If(ORDTYPE='SL', If(Len(SLS.IVNO) > 0, SLS.IVNO, ''))) AS IVCOUNT

or

=COUNT(DISTINCT If(ORDTYPE='SL', If(IsNull(SLS.IVNO), SLS.IVNO, ''))) AS IVCOUNT

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Not applicable
Author

hi,

thanks for the reply.

i have tried both, but i m getting error as invalid expression.

this is my script.

Sales:

LOAD BRCODE,

      COUNT(DISTINCT If(ORDTYPE='SL', If(Len(IVNO) > 0,IVNO, ''))) AS IVCOUNT ,

     IVDT,

    sum(SPAMT) as NETSL,

     CPAMT

  

FROM

[\QVData\SALES.qvd]

(qvd);

any other suggestions plssssss

Not applicable
Author

Try this..

Sales:

LOAD BRCODE,

      COUNT(DISTINCT If(ORDTYPE='SL', If(Len(IVNO) = 0,'NULL',IVNO))) AS IVCOUNT ,

     IVDT,

    sum(SPAMT) as NETSL,

     CPAMT

  

FROM

[\QVData\SALES.qvd]

(qvd);

mato32188
Specialist
Specialist

Hi PRRAJENDRAN,

guys have suggested right solutions, but you are missing GROUP BY statement as the very last one (after (qvd)...).

M

ECG line chart is the most important visualization in your life.
Not applicable
Author

With Group By

Sales:

BRCODE,
COUNT(DISTINCT If(ORDTYPE='SL', If(Len(IVNO) = 0,'NULL',IVNO))) AS IVCOUNT ,
    
IVDT,
   
sum(SPAMT) as NETSL,

    
CPAMT
FROM
[\QVData\SALES.qvd](
qvd)
GROUP BY
BRCODE
IVDT,
CPAMT
;

Not applicable
Author

hi

how should i give that group by.

can u please help me with the script.???

actually i have used this

group by BRCODE

but still error

mato32188
Specialist
Specialist

...(qvd)

GROUP BY yourFieldName1, yourFieldName2, yourFieldName3 ;

Keep order of columns by your grouping preferences.

M

ECG line chart is the most important visualization in your life.
Not applicable
Author

Mark with Correct Answer, if any of the above suggested solutions  worked.