Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
steps1989
Contributor II
Contributor II

Invoice Count By Invoice No

Hello Everyone ,

 

i have invoice table (invoice no , invoice type , Net sold QTY ,  NET AMT...etc)

invoice type : (Regular  - Return ) 

i want to count invoices as a net count ( Count Regular invoice - Count Return invoice )

any help to make case function to calculate that value

------------------------------------------------------------------------------

INVOICE:
LOAD *,
date(CREATED_DATE ,'MM/DD/YYYY') as INVC_CREATED_DATE,
Time(CREATED_DATE ,'HH:MI:SS') as INVC_CREATED_TIME,
year (CREATED_DATE) as INVCYEAR,
month (CREATED_DATE) as INVCMONTH,
week (CREATED_DATE) as INVCWEEK,
day (CREATED_DATE) as INVCDAYS,
Num(TAX_AMT) as TAXAMT;

select t.ITEM_SID,
i.SBS_NO as INVC_SBS,
i.STORE_NO,
i.INVC_NO,
i.CREATED_DATE,
to_char(i.CREATED_DATE,'HH24') as Post_Hour,
i.INVC_SID,
i.INVC_TYPE,
i.DISC_PERC,
i.DISC_AMT,
i.CASHIER_ID,
to_char(i.CREATED_DATE) as INVCDATE,
t.ORIG_PRICE as INVCORIGPRICE,
t.PRICE as INVCPRICE,
t.ORIG_TAX_AMT,
t.TAX_AMT,
t.DISC_REASON_ID,
t.COST as INVCCOST,
case
when i.INVC_TYPE = 2
then t.QTY * - 1
else t.QTY
end as INVCQTY,

case i.INVC_TYPE
when 0 then 'REGULAR'
when 2 then 'RETURN'
else 'NA'
end as INVCTYPE,

Labels (3)
1 Solution

Accepted Solutions
martinpohl
Partner - Master
Partner - Master

sure

count({<INVCTYPE={REGULAR}>} distinct INVC_NO) - count({<INVCTYPE={RETURN}>} distinct INVC_NO)

some brackets are missing

View solution in original post

4 Replies
martinpohl
Partner - Master
Partner - Master

count({<INVCTYPE={REGULAR>} distinct INVC_NO) - count({<INVCTYPE={RETURN>} distinct INVC_NO)

steps1989
Contributor II
Contributor II
Author

Actually its giving error in expression

martinpohl
Partner - Master
Partner - Master

sure

count({<INVCTYPE={REGULAR}>} distinct INVC_NO) - count({<INVCTYPE={RETURN}>} distinct INVC_NO)

some brackets are missing

steps1989
Contributor II
Contributor II
Author

Thanks for your help , its working fine but i need to get total invoice count , how it will be ?