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

Joins: one to Many.

Good evening.

I am struggling to develop a model where I can see sell trough's in our retail stores.

My sales consist of multiple lines in the database, and my stock on hand equals one line per store per stock code.  I can join the two tables on Store and Stock code, but I am not sure ho to use this correctly in my qlikview model.

Sum(Sales) gives me the correct sales. sum(Stock on hand) gives me an inflated value.

Sell through = sum(sales for the week)/Stock on Hand.

Hopefully my question makes sense?

Regards.

4 Replies
robert_mika
Master III
Master III

Not seeing your data but  guess you need to group the Sales lines and then use join in your data model.

Post sample of your data or the app to give more correct solution.

Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi Thomas,

yes, your question makes a perfect sense, and this is one of the most difficult issues in QlikView data modeling - how to load multiple fact tables with different granularity and how to keep different metrics in order, despite the different granularity.

First of all, you certainly don't want to JOIN the two tables, because of the problem you already mentioned - your Stock data will get multiplied by the number of Sales rows per Product and Store.

Basically you have three choices (I would personally support two of them):

1. Load your data "as is" and let it link "as is" without worrying too much about data modeling. In this case, you are likely to get one or more Synthetic keys and in some extreme cases, your data model may get linked incorrectly. While these models can sometimes work with small and simple datasets, I usually discourage developers from doing that.

2. Link your multiple fact tables using the data modelling technique called the "Link Table". This structure is slightly better than the previous one, because it explicitly replaces the Synthetic keys with your explicitly defined concatenated key fields, and if you do it right, you can avoid most of the data modelling pitfalls such as data duplication. The downside of these models is that they tend to be heavy on large datasets, for a variety of reasons that need to be described in a separate article. So, this option is only viable with a relatively small and simple data set.

3.  Concatenate your multiple fact tables into a "Single Fact" model. This is the best performing and the most robust analytical data model. The challenge here is to restore associations that get "lost" when you concatenate your facts (Sales and Inventory, for example) instead of linking them. For example, if you selected a Customer (or Salesperson, or any other attribute of Sales) and wanted to see Inventory that is associated with them, you could easily do it with a Link Table but it's less trivial with the Single Fact. There are techniques to overcome that, too. For larger data sets, this is the only viable option.

I recommend that you check out my new book QlikView Your Business. In the book, I describe in detail how to build a Link Table and how to build a Single Fact model, and how to overcome challenges related to both models. This is the most detailed explanation of these techniques in the existing QlikView literature. In addition, one of the three main parts of the book is focused on Inventory Analysis, which may help you with your particular application.

best,

Oleg Troyansky

Check out my new book QlikView Your Business: An expert guide to Business Discovery with QlikView an...

Not applicable
Author

I am new to the forum so I am not 100% how to include the data.

Hopefully the below sample helps.

Table 1 Table 2
salesStock on hand
dtinvoiceskuqty soldskusoh
2015/10/261235879A1A10
2015/10/271235880A6B10
2015/10/281235881A73C10
2015/10/291235882B6
2015/10/301235883C8
2015/10/311235884A5
2015/11/011235885B5
Not applicable
Author

Thank you for the detailed response.

I will play with option 3 for now and see if I get it right.