The Data table contains a Document and Orders booked against the document. Each Order has a Code and a creation Date.
The Documents table contains info about the Document - Validity Start, Validity End, Planned Value, Actual Value
The Division table shows which of the company's Divisions created the Order
So everything is cool until I put this into a table. Then if there is a document that has more than one order and a missing division, the measures show zero:
This can be avoided by including Order as an additional dimension:
However, I do not want to do this as in the real dataset one document might have hundreds of orders booked against it on the same date and the table becomes huge. Therefore, the level of detail that I need is as shown in the first table.
The best solution I have come up with is to use Aggr() like this:
This solves my problem but kind of slows down the app, which I do not like...
So, two questions:
Why Qlik behaves like this and does not calculate the values correctly in the first table?
Do you think that my solution using Aggr() is acceptable or there is a better way? I would like to keep the calculation in the front end without changing the script.
I think there is no point in showing the second record as it doesn't have a division associated, its like a full outer join
but if the business asks then we have to show it ...
if you really want you can suppress the second record so that it doesn't come up, as you said in real situation you might be ended up showing multiple records which may not be give any value to the business
or even simpler - you could left join in the Division names to the Data table like this:
LEFT JOIN (Data)
LOAD * INLINE [
Then you could keep your simple Sum(Value_Planned) and Sum(Valule_Actual) and get the two rows you need.
The problem is really in the Divisions table which is inconsistent with the Data (orders) table. So you should either cleanse and fix the Divisions table during the load script phase by adding the Code for the divisions that doesn't exist in the Data (orders) table. This follows normal Business Intelligence and Data Warehouse best practices - which says that you shouldn't have dimension keys in a fact table that hasn't corresponding keys in the dimension table.
Thanks a lot! Sum(Total <Document> Value) did the trick. It provides the same result as my Aggr() solution but is much faster and does not slow down the app! Exactly what i needed! Btw. I never used this syntax, is it something like set analysis? Could you please tell me how is it called or where I could read more about it?
Also thank you for explaining the reason why my table did not work. So when a dimensional value is missing Qlik will not calculate the measures as I would expect it to. I will not change the script of this particular app, but what you posted as suggestion is very interesting and I would use it in future.