Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
I'm new at Qlickview and hope anyone can help me with the following:
I have customerdata with customernumbers and ordernumbers and want to know the NumberOrder; meaning per customer if it's the first, second or third (or more) order.
I thought of using next and previous syntax (although i'm not sure what those look like), and tried the following (new formulas in bold):
Load
// "No_" as DocumentNo
"Document No_"&'-'&"No_" as DocuItemNo
, "Sell-to Customer No_"as CustomerNo
, "Package Tracking No_" as PackageTrackingNo
, "Promotion Name" as PromotionName
, "Promotion ID" as PromotionID
, "Discount Description" as DiscountDescription
, IF (NEXT(CustomerNo)=CustomerNo, CustomerNo,1) AS OrderCode
// so for customers who placed more orders, those orders will be coded with 1 and then we can calculate NumberOrder
, IF (PREVIOUS(CustomerNo)=CustomerNo, PREVIOUS(OrderCode)+1,1) as NumberOrder;
SQL SELECT
"Document No_"
, "Sell-to Customer No_"
, "No_"
, "Package Tracking No_"
, "Promotion Name"
, "Promotion ID"
, "Discount Description"
FROM "$(DB_DATASOURCE)".dbo."$(DB_COMPANY)$Sales Invoice Line"
ORDER BY "Sell-to Customer No_";
But this is not working... Does anyone have a solution?
Regards,
Eline
Hi,
Then try with peek function instead of Previous.
CustomerDocument:
Load
// "No_" as DocumentNo
"Document No_"&'-'&"No_" as DocuItemNo
, CustomerNo
, "Package Tracking No_" as PackageTrackingNo
, "Promotion Name" as PromotionName
, "Promotion ID" as PromotionID
, "Discount Description" as DiscountDescription
, IF (PEEK('CustomerNo')=CustomerNo, PEEK('NumberOrder')+1,1) as NumberOrder;
SQL SELECT
"Document No_"
, "Sell-to Customer No_" as CustomerNo
, "No_"
, "Package Tracking No_"
, "Promotion Name"
, "Promotion ID"
, "Discount Description"
FROM "$(DB_DATASOURCE)".dbo."$(DB_COMPANY)$Sales Invoice Line"
ORDER BY "Sell-to Customer No_";
Celambarasan
Edit:Added single quotes in the peek function. Message was edited by: Celambarasan Adhimulam