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

Showing all records from one fact table where no associated data exists in a second fact table

Hi Folks,

I have a problem that I'm trying to overcome in a chart and I'm hoping I don't need to create bogus records in the script.

I have an inventory file that contains inventory balances of all items. I am bringing in sales data and summarizing the rows by item and MonthYear with a QVD from a Sales Application. I'm trying to determine the slow moving items using the rolling 12 month sales (for example by selection Jan-2010 through Dec-2010). The resulting chart is based on 12 months selected and looks like this:

ItemDescriptionOn Hand12 Months Rolling SalesExcess Inventory 24 MonthsExcess Inventory 12 Months
1234XYZ5222822


The problem I've come to realize is that if I have no sales for the selected periods and there is inventory, no row will be presented since the selection will only bring in invenotry records for which there is sales. Can anyone think of a way to force all records from the inventory file even if there is no sales data present for the selected MonthYear? Ideally the resulting chart would contain a row for item 1235 where there is inventory and no associated sales data is present:

ItemDescriptionOn Hand12 Months Rolling SalesExcess Inventory 24 MonthsExcess Inventory 12 Months
1234XYZ22222222
1235ABC100100


Thanks,

Rich De Rocco

1 Solution

Accepted Solutions
Not applicable
Author

Hi Rich,

When bringing in the data, are the Sales and Inventory coming in separately? If so, you could create a LINK table that brings the comon data elements in with an OUTER JOIN.

ie:

Sales:
SQL SELECT
*
,Date & Item_Id & Description AS '%Sales_Key'
FROM SALES;

Inventory:
SQL SELECT
*
,,Date & Item_Id & Description AS '%Inventory_Key'
FROM INVENTORY;

Link_Sales_Inventory:
LOAD
Date
,Item_Id
,Description
,'%Sales_Key'
RESIDENT Sales;

OUTER JOIN (Link_Sales_Inventory)
LOAD
Date
,Item_Id
,Description
,'%Inventory_Key'
RESIDENT Inventory;

DROP FIELDS
Date
,Item_Id
,Description
FROM sales, Inventory;

Thanks,

Aline

View solution in original post

2 Replies
Not applicable
Author

Hi Rich,

When bringing in the data, are the Sales and Inventory coming in separately? If so, you could create a LINK table that brings the comon data elements in with an OUTER JOIN.

ie:

Sales:
SQL SELECT
*
,Date & Item_Id & Description AS '%Sales_Key'
FROM SALES;

Inventory:
SQL SELECT
*
,,Date & Item_Id & Description AS '%Inventory_Key'
FROM INVENTORY;

Link_Sales_Inventory:
LOAD
Date
,Item_Id
,Description
,'%Sales_Key'
RESIDENT Sales;

OUTER JOIN (Link_Sales_Inventory)
LOAD
Date
,Item_Id
,Description
,'%Inventory_Key'
RESIDENT Inventory;

DROP FIELDS
Date
,Item_Id
,Description
FROM sales, Inventory;

Thanks,

Aline

Not applicable
Author

Thanks AQline,

I was afraid of that. I was hoping to get away with just a chart function.

Rich

Thanks Aline.

Just got around to making the change.

Rich