You are on page 1of 17

MasterBilling:

LOAD

"Location Name" ,

if("Location Name"='IN - PHI Corporate' and Right("Product Code",4) = '2101','Bulk',

if("Customer Code" = 1010425611 , 'IN - Jabalpur',

if("Customer Code" = 1010426198, 'IN - Ludhiana',

if("Customer Code" = 1010426305, 'IN - Davanagere',

if("Customer Code" = 1010427669, 'IN - Bhubaneshwar',

if("Customer Code" = 1010428055, 'IN - Jabalpur',

if("Customer Code" = 1010445274, 'IN - Hisar',

if("Customer Code" = 1010462558, 'IN - Ludhiana',

if("Customer Code" = 1010472414, 'IN - Raipur',

if("Customer Code" = 1010504728, 'IN - Ludhiana',

if("Customer Code" = 1010554097, 'IN - Trichy',

if("Customer Code" = 1010555732, 'IN - Jabalpur',

// if("Location Name"='IN - PHI Corporate' and Right("Product Code",4) <> '2101','Subsidised',

if ("Location Name"<>'IN - PHI Export',"Location Name",if("Customer District" ='Paro','Bhutan',

if("Customer District" ='Birganj','Nepal','Bangladesh'))))))))))))))) as SAP_Location,

"Season Code",

"Invoice Number",

"Invoice Date",

year ("Invoice Date") as Year,

month ("Invoice Date") as Month,

"Product Code",

if("Location Name"='IN - PHI Corporate' and Right("Product Code",4) <> '2101','Subsidised','Trade')


as Trade_Type,
"Product Description",

"Hybrid Code",

"Crop Description",

"UOM Kgs",

"Customer Code",

"Customer Name",

"Customer State Name",

"Customer District",

"Warehouse Code",

"Warehouse Description",

"St. Loc.",

"Distributor Price",

"Product Basic Amount",

"ABS Discount",

"NORMAL DISCOUNT",

"Retail Flat Discount",

"Invoice Amount"

FROM [lib://Billing/2015 Billing.XLSX]

(ooxml, embedded labels, table is Sheet1)

where "Location Name" <> 'IN - Non-Comm Sale' and "Crop Description" <> 'Plant inoculant' and "St.
Loc." <> 9999 ;

join LOAD

"Location Name" ,

if("Location Name"='IN - PHI Corporate' and Right("Product Code",4) = '2101','Bulk',


if("Customer Code" = 1010425611 , 'IN - Jabalpur',

if("Customer Code" = 1010426198, 'IN - Ludhiana',

if("Customer Code" = 1010426305, 'IN - Davanagere',

if("Customer Code" = 1010427669, 'IN - Bhubaneshwar',

if("Customer Code" = 1010428055, 'IN - Jabalpur',

if("Customer Code" = 1010445274, 'IN - Hisar',

if("Customer Code" = 1010462558, 'IN - Ludhiana',

if("Customer Code" = 1010472414, 'IN - Raipur',

if("Customer Code" = 1010504728, 'IN - Ludhiana',

if("Customer Code" = 1010554097, 'IN - Trichy',

if("Customer Code" = 1010555732, 'IN - Jabalpur',

// if("Location Name"='IN - PHI Corporate' and Right("Product Code",4) <> '2101','Subsidised',

if ("Location Name"<>'IN - PHI Export',"Location Name",if("Customer District" ='Paro','Bhutan',

if("Customer District" ='Birganj','Nepal','Bangladesh'))))))))))))))) as SAP_Location,

"Season Code",

"Invoice Number",

"Invoice Date",

year ("Invoice Date") as Year,

month ("Invoice Date") as Month,

"Product Code",

if("Location Name"='IN - PHI Corporate' and Right("Product Code",4) <> '2101','Subsidised','Trade')


as Trade_Type,

"Product Description",

"Hybrid Code",

"Crop Description",

"UOM Kgs",

"Customer Code",
"Customer Name",

"Customer State Name",

"Customer District",

"Warehouse Code",

"Warehouse Description",

"St. Loc.",

"Distributor Price",

"Product Basic Amount",

"ABS Discount",

"NORMAL DISCOUNT",

"Retail Flat Discount",

"Invoice Amount"

FROM [lib://Billing/2016 Billing.XLSX]

(ooxml, embedded labels, table is Sheet1)

where "Location Name" <> 'IN - Non-Comm Sale' and "Crop Description" <> 'Plant inoculant' and "St.
Loc." <> 9999 ;

join LOAD

"Location Name" ,

if("Location Name"='IN - PHI Corporate' and Right("Product Code",4) = '2101','Bulk',

if("Customer Code" = 1010425611 , 'IN - Jabalpur',

if("Customer Code" = 1010426198, 'IN - Ludhiana',

if("Customer Code" = 1010426305, 'IN - Davanagere',

if("Customer Code" = 1010427669, 'IN - Bhubaneshwar',

if("Customer Code" = 1010428055, 'IN - Jabalpur',

if("Customer Code" = 1010445274, 'IN - Hisar',


if("Customer Code" = 1010462558, 'IN - Ludhiana',

if("Customer Code" = 1010472414, 'IN - Raipur',

if("Customer Code" = 1010504728, 'IN - Ludhiana',

if("Customer Code" = 1010554097, 'IN - Trichy',

if("Customer Code" = 1010555732, 'IN - Jabalpur',

// if("Location Name"='IN - PHI Corporate' and Right("Product Code",4) <> '2101','Subsidised',

if ("Location Name"<>'IN - PHI Export',"Location Name",if("Customer District" ='Paro','Bhutan',

if("Customer District" ='Birganj','Nepal','Bangladesh'))))))))))))))) as SAP_Location,

"Season Code",

"Invoice Number",

"Invoice Date",

year ("Invoice Date") as Year,

month ("Invoice Date") as Month,

"Product Code",

if("Location Name"='IN - PHI Corporate' and Right("Product Code",4) <> '2101','Subsidised','Trade')


as Trade_Type,

"Product Description",

"Hybrid Code",

"Crop Description",

"UOM Kgs",

"Customer Code",

"Customer Name",

"Customer State Name",

"Customer District",

"Warehouse Code",
"Warehouse Description",

"St. Loc.",

"Distributor Price",

"Product Basic Amount",

"ABS Discount",

"NORMAL DISCOUNT",

"Retail Flat Discount",

"Invoice Amount"

FROM [lib://Billing/2017 Billing.XLSX]

(ooxml, embedded labels, table is Sheet1)

where "Location Name" <> 'IN - Non-Comm Sale' and "Crop Description" <> 'Plant inoculant' and "St.
Loc." <> 9999 ;

join LOAD

"Location Name" ,

if("Location Name"='IN - PHI Corporate' and Right("Product Code",4) = '2101','Bulk',

if("Customer Code" = 1010425611 , 'IN - Jabalpur',

if("Customer Code" = 1010426198, 'IN - Ludhiana',

if("Customer Code" = 1010426305, 'IN - Davanagere',

if("Customer Code" = 1010427669, 'IN - Bhubaneshwar',

if("Customer Code" = 1010428055, 'IN - Jabalpur',

if("Customer Code" = 1010445274, 'IN - Hisar',

if("Customer Code" = 1010462558, 'IN - Ludhiana',

if("Customer Code" = 1010472414, 'IN - Raipur',

if("Customer Code" = 1010504728, 'IN - Ludhiana',

if("Customer Code" = 1010554097, 'IN - Trichy',


if("Customer Code" = 1010555732, 'IN - Jabalpur',

// if("Location Name"='IN - PHI Corporate' and Right("Product Code",4) <> '2101','Subsidised',

if ("Location Name"<>'IN - PHI Export',"Location Name",if("Customer District" ='Paro','Bhutan',

if("Customer District" ='Birganj','Nepal','Bangladesh'))))))))))))))) as SAP_Location,

"Season Code",

"Invoice Number",

"Invoice Date",

year ("Invoice Date") as Year,

month ("Invoice Date") as Month,

"Product Code",

if("Location Name"='IN - PHI Corporate' and Right("Product Code",4) <> '2101','Subsidised','Trade')


as Trade_Type,

"Product Description",

"Hybrid Code",

"Crop Description",

"UOM Kgs",

"Customer Code",

"Customer Name",

"Customer State Name",

"Customer District",

"Warehouse Code",

"Warehouse Description",

"St. Loc.",
"Distributor Price",

"Product Basic Amount",

"ABS Discount",

"NORMAL DISCOUNT",

"Retail Flat Discount",

"Invoice Amount"

FROM [lib://Billing/2018 Billing.XLSX]

(ooxml, embedded labels, table is Sheet1)

where "Location Name" <> 'IN - Non-Comm Sale' and "Crop Description" <> 'Plant inoculant' and "St.
Loc." <> 9999 ;

MasterReturn:

LOAD

"Location Name" ,

if("Location Name"='IN - PHI Corporate' and Right("Product Code",4) = '2101','Bulk',

if("Customer Code" = 1010425611 , 'IN - Jabalpur',

if("Customer Code" = 1010426198, 'IN - Ludhiana',

if("Customer Code" = 1010426305, 'IN - Davanagere',

if("Customer Code" = 1010427669, 'IN - Bhubaneshwar',

if("Customer Code" = 1010428055, 'IN - Jabalpur',

if("Customer Code" = 1010445274, 'IN - Hisar',

if("Customer Code" = 1010462558, 'IN - Ludhiana',

if("Customer Code" = 1010472414, 'IN - Raipur',

if("Customer Code" = 1010504728, 'IN - Ludhiana',

if("Customer Code" = 1010554097, 'IN - Trichy',

if("Customer Code" = 1010555732, 'IN - Jabalpur',


// if("Location Name"='IN - PHI Corporate' and Right("Product Code",4) <> '2101','Subsidised',

if ("Location Name"<>'IN - PHI Export',"Location Name",if("Customer District" ='Paro','Bhutan',

if("Customer District" ='Birganj','Nepal','Bangladesh'))))))))))))))) as SAP_Location,

"Season Code",

"Credit Memo Dt",

year ("Credit Memo Dt") as Year,

month ("Credit Memo Dt") as Month,

"Product Code",

if("Location Name"='IN - PHI Corporate' and Right("Product Code",4) <> '2101','Subsidised','Trade')


as Trade_Type,

"Product Description",

"Hybrid Code",

"Crop Description",

"UOM Kgs" as Return,

"Customer Code",

"Customer Name",

"Customer State Name",

"Customer District",

"Warehouse Code",

"Warehouse Description",

"St. Loc.",
"Distributor Price",

"Product Basic Amount",

"ABS Discount",

"NORMAL DISCOUNT",

"Retail Flat Discount",

"Invoice Amount" as Return_Value

FROM [lib://Billing/Return\2015 Return.XLSX]

(ooxml, embedded labels, table is Sheet1)

where "Location Name" <> 'IN - Non-Comm Sale' and "Crop Description" <> 'Plant inoculant' and "St.
Loc." <> 9999 ;

Join

LOAD

"Location Name" ,

if("Location Name"='IN - PHI Corporate' and Right("Product Code",4) = '2101','Bulk',

if("Customer Code" = 1010425611 , 'IN - Jabalpur',

if("Customer Code" = 1010426198, 'IN - Ludhiana',

if("Customer Code" = 1010426305, 'IN - Davanagere',

if("Customer Code" = 1010427669, 'IN - Bhubaneshwar',

if("Customer Code" = 1010428055, 'IN - Jabalpur',

if("Customer Code" = 1010445274, 'IN - Hisar',

if("Customer Code" = 1010462558, 'IN - Ludhiana',

if("Customer Code" = 1010472414, 'IN - Raipur',

if("Customer Code" = 1010504728, 'IN - Ludhiana',

if("Customer Code" = 1010554097, 'IN - Trichy',

if("Customer Code" = 1010555732, 'IN - Jabalpur',


if ("Location Name"<>'IN - PHI Export',"Location Name",if("Customer District" ='Paro','Bhutan',

if("Customer District" ='Birganj','Nepal','Bangladesh'))))))))))))))) as SAP_Location,

"Season Code",

"Credit Memo Dt",

year ("Credit Memo Dt") as Year,

month ("Credit Memo Dt") as Month,

"Product Code",

if("Location Name"='IN - PHI Corporate' and Right("Product Code",4) <> '2101','Subsidised','Trade')


as Trade_Type,

"Product Description",

"Hybrid Code",

"Crop Description",

"UOM Kgs" as Return,

"Customer Code",

"Customer Name",

"Customer State Name",

"Customer District",

"Warehouse Code",

"Warehouse Description",

"St. Loc.",
"Distributor Price",

"Product Basic Amount",

"ABS Discount",

"NORMAL DISCOUNT",

"Retail Flat Discount",

"Invoice Amount" as Return_Value

FROM [lib://Billing/Return\2016 2018 return.XLSX]

(ooxml, embedded labels, table is Sheet1)

where "Location Name" <> 'IN - Non-Comm Sale' and "Crop Description" <> 'Plant inoculant' and "St.
Loc." <> 9999;

Lookup_Key:

LOAD

Date_ID,

Year,

Month

FROM [lib://Qlik/Date_Week.xlsx]

(ooxml, embedded labels, table is Date_Week);

join

LOAD

SAP_Location
FROM [lib://Qlik/Area previous.xlsx]

(ooxml, embedded labels, table is Area);

Join

LOAD

Hybrid

FROM [lib://Qlik/Hybrid.xlsx]

(ooxml, embedded labels, table is Hybrid);

join

LOAD

Trade_Type

FROM [lib://Qlik/Trade_Type.xlsx]

(ooxml, embedded labels, table is Sheet1);

Daily_Inv:

Load

"Invoice Date" & SAP_Location & "Hybrid Code" as Key,

"UOM Kgs" as Billing,

Trade_Type,
"Invoice Amount" as Billing_Revenue

Resident MasterBilling;

drop Table MasterBilling;

Daily_Ret:

Load

"Credit Memo Dt" & SAP_Location & "Hybrid Code" as Key,

Return,

Trade_Type,

Return_Value

Resident MasterReturn;

drop Table MasterReturn;

Key_Master:

Load

Date_ID & SAP_Location & Hybrid as Key,

Date_ID,

SAP_Location,

Hybrid,

Trade_Type,
"Year" & "Month" & SAP_Location & Hybrid as Key1

Resident Lookup_Key;

Drop Table Lookup_Key;

PO:

LOAD

"Year" & "Month" & "SAP_Location" & Hybrid as Key1,

PO,

Rev,

NB

FROM [lib://Qlik/PO1.xlsx]

(ooxml, embedded labels, table is PO);

RSP:

LOAD

"Year" & "Month" & "SAP_Location" & Hybrid as Key1,

CM_Plan AS RSP,

"CM+1_Plan" AS "RSP+1",

"CM+2_Plan" AS "RSP+2"

FROM [lib://Qlik/RSP.xlsx]

(ooxml, embedded labels, table is RSP);

Liq:
LOAD

Liq_Pub_Date & SAP_Location & Hybrid as Key,

S_Year,

Liq_YTD,

Liq_Weekly

FROM [lib://Qlik/Liquidation Master 2.xlsx]

(ooxml, embedded labels, table is Liq);

Calendar:

LOAD

Date_ID,

Year,

Month,

Quarter,

"Days",

"Week",

Weekdays

FROM [lib://Qlik/Date_Week.xlsx]

(ooxml, embedded labels, table is Date_Week);

Area:

LOAD

SAP_Location,

Area,
Region

FROM [lib://Qlik/Area previous.xlsx]

(ooxml, embedded labels, table is Area);

Product:

LOAD

Hybrid,

Crop,

Brand,

Season

FROM [lib://Qlik/Hybrid.xlsx]

(ooxml, embedded labels, table is Hybrid);

LOAD

Trade_Type

FROM [lib://Qlik/Trade_Type.xlsx]

(ooxml, embedded labels, table is Sheet1);

You might also like