Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
dafnis14
Specialist
Specialist

How to link 2 Fact tables that share Hierarchy and a key

Hi,

After exploring numerous blogs and discussions (like the one below)

https://community.qlik.com/message/547634#547634

I still couldn't figure out a solution for my issue..

I have a balanced  Hierarchy:

Delivery > Offer >Item

Hierarchy.png

One fact table (Deliveries) is link to the highest level (DeliveryID) and one (Customer Returns) to the lowest (Key_Delivery_Offer_Item).

Facts_Link_to_Dimensions.png

For both I need to sum by the item level which is working fine:

Metrics_Delivered_Returned.png

But when I add the customer key, I get a circular reference:

Circular_in_hierarchy.png

I think Generic Key or concatenation is not a solution because I need all the hiearchy levels for both fact tables.

Any idea how to handle this?

Thanks!

40 Replies
dafnis14
Specialist
Specialist
Author

count({<Returned.ReturnedFlag={1}>}DISTINCT DeliveryID)

Please note that here I need summary, so customerID is not a dimension.

I need to know how many items were returned

Thanks!

vinieme12
Champion III
Champion III

try

count({<%KEY_ReturnedDelivery={"=(Returned.ReturnedFlag)=1"}>}DISTINCT DeliveryID)

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
dafnis14
Specialist
Specialist
Author

I did...

But it shows items that were not returned as well:

total_ret.png

Thanks!

vinieme12
Champion III
Champion III

As i said earlier, you cannot have ItemName as dimension in the Delivered table

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
vinieme12
Champion III
Champion III

if you actually had Item details in the Delivered table then we could have created a key that had CustomerID+DeliveryID+ItemID

but your data sample simply doesn't has that info, so you can only use ItemName in the returned info table

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
dafnis14
Specialist
Specialist
Author

The reason I don't create the details for deliveries is because it'll be a huge file.

But the problem now is with the returned items, and they have itemID.

Sorry, I don't understand...

vinieme12
Champion III
Champion III

let me check

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
vinieme12
Champion III
Champion III

You are using the wrong ItemName field, you should be using Returned.ItemID

I've added ItemName to the returned table, you can choose to join or Keep them in a separate table.

I've just commented the Join statement in the script

sample2.JPG

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
dafnis14
Specialist
Specialist
Author

Thanks again for your huge efforts!

So, basically, I cannot show returned & delivered metrics in the same table, only separate?

vinieme12
Champion III
Champion III

Nope You can't

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.