Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
We load data from the service we use via the REST connector. Below is a simplified script that represents the data structure (entities and keys) we got:
[tickets]:
Load
tickets.id,
tickets.requester_id as contacts.id,
tickets.responder_id as agents.id
// Other fields are omitted for simplicity
Inline [
tickets.id, tickets.requester_id, tickets.responder_id
1, 2, 3
2, 3, 1
3, 3, 2
4, 1, 2
];
[conversations]:
Load
conversations.id,
conversations.ticket_id as tickets.id,
conversations.contact_id as contacts.id, // If contact_id is set, then agent_id will be empty (conversation can belong to either contact or agent)
conversations.agent_id as agents.id // If agent_id is set, then agent_id will be empty (conversation can belong to either contact or agent)
// Other fields are omitted for simplicity
Inline [
conversations.id, conversations.ticket_id, conversations.contact_id, conversations.agent_id
1, 1, 2, 2
2, 1, 1, 2
3, 2, 3, 1
4, 4, 2, 3
];
[contacts]:
Load
contacts.id
// Other fields are omitted for simplicity
Inline [
contacts.id
1,
2,
3
];
[agents]:
Load
agents.id
// Other fields are omitted for simplicity
Inline [
agents.id
1,
2,
3
];
This results in a Synthetic key:
$Syn 1 = tickets.id+contacts.id+agents.id
We have seen the Qlik documentation on synthetic keys, where it states that renaming one or more fields in the tables is a solution, but we are not sure that this is possible in this case because there are the following requirements:
--------------------------------------------------------------------------------------------------------
conversations entity:
tickets entity:
contacts entity:
agents entity:
--------------------------------------------------------------------------------------------------------
It seems that if we rename/remove one or more fields from any entity, then we will lose the relationship/ability to implement at least one of the above requirements? 🤔
Do you have any suggestions on how we can resolve this?
Hi @RoyBatty ,
What about this:
[tickets]:
Load
tickets.id,
tickets.requester_id as requester_id,
tickets.responder_id as responder_id
Inline [
tickets.id, tickets.requester_id, tickets.responder_id
1, 2, 3
2, 3, 1
3, 3, 2
4, 1, 2
];
[Requesters]:
Load
contacts.id as requester_id
// Other fields are omitted for simplicity
Inline [
contacts.id
1,
2,
3
];
[Responders]:
Load
agents.id as responder_id
// Other fields are omitted for simplicity
Inline [
agents.id
1,
2,
3
];
[conversations]:
Load
conversations.id,
conversations.ticket_id as tickets.id,
conversations.contact_id as contacts.id, // If contact_id is set, then agent_id will be empty (conversation can belong to either contact or agent)
conversations.agent_id as agents.id // If agent_id is set, then agent_id will be empty (conversation can belong to either contact or agent)
// Other fields are omitted for simplicity
Inline [
conversations.id, conversations.ticket_id, conversations.contact_id, conversations.agent_id
1, 1, 2, 2
2, 1, 1, 2
3, 2, 3, 1
4, 4, 2, 3
];
[contacts]:
Load
contacts.id
// Other fields are omitted for simplicity
Inline [
contacts.id
1,
2,
3
];
[agents]:
Load
agents.id
// Other fields are omitted for simplicity
Inline [
agents.id
1,
2,
3
];
Hi @RoyBatty ,
What about this:
[tickets]:
Load
tickets.id,
tickets.requester_id as requester_id,
tickets.responder_id as responder_id
Inline [
tickets.id, tickets.requester_id, tickets.responder_id
1, 2, 3
2, 3, 1
3, 3, 2
4, 1, 2
];
[Requesters]:
Load
contacts.id as requester_id
// Other fields are omitted for simplicity
Inline [
contacts.id
1,
2,
3
];
[Responders]:
Load
agents.id as responder_id
// Other fields are omitted for simplicity
Inline [
agents.id
1,
2,
3
];
[conversations]:
Load
conversations.id,
conversations.ticket_id as tickets.id,
conversations.contact_id as contacts.id, // If contact_id is set, then agent_id will be empty (conversation can belong to either contact or agent)
conversations.agent_id as agents.id // If agent_id is set, then agent_id will be empty (conversation can belong to either contact or agent)
// Other fields are omitted for simplicity
Inline [
conversations.id, conversations.ticket_id, conversations.contact_id, conversations.agent_id
1, 1, 2, 2
2, 1, 1, 2
3, 2, 3, 1
4, 4, 2, 3
];
[contacts]:
Load
contacts.id
// Other fields are omitted for simplicity
Inline [
contacts.id
1,
2,
3
];
[agents]:
Load
agents.id
// Other fields are omitted for simplicity
Inline [
agents.id
1,
2,
3
];
So basically, create a duplicate tables:
We are not sure if this is the best solution because:
Actually, we are not sure, maybe no other/better way is possible to handle this. Anyway, we'll give it some thought, test it, and see how it goes... and come back here to conclude 🙂 Thank you!
That is the beauty of Qlik. In Global Search Bar, if you type for John Smith, it will show up on both Agents and Responders fields. So, separated tables/fields are classifying in advance the role of the agent in different contexts. This will be specially interesting if you use Left Keep to reduce the agent source table by the context (agent or responders) so you can have a complete list of Agents or Responders.
It is possible to keep Agents and Responders in one single table but his is way trickier and I'm not sure if this will improve the usability of the app and the craft of the Expressions. Maybe joining the Conversations to the Tickets folder + multiplying records on Agents and Contacts tables + some field manipulation will do the magic.
I would add that, in addition to the solution that @marksouzacosta offered, another option is to leave the synthetic key:
then there should be no problem handling it, nor should there be any problem with excessive amount of time and/or memory.
--------------------------------------------------
UPDATE:
One more note: In case you decide to keep synthetic key, use separate keys for relations. In our example (given above), the following synthetic key is formed:
$Syn 1 = tickets.id+contacts.id+agents.id
So we will add keys in all those tables: %ticket_id, %contact_id and %agent_id:
[tickets]:
Load
tickets.id,
tickets.id as %ticket_id, // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
tickets.requester_id as %contact_id, // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
tickets.responder_id as %agent_id // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
// Other fields are omitted for simplicity
Inline [
tickets.id, tickets.requester_id, tickets.responder_id
1, 2, 3
2, 3, 1
3, 3, 2
4, 1, 2
];
[conversations]:
Load
conversations.id,
conversations.ticket_id as %ticket_id, // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
conversations.contact_id as %contact_id, // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
conversations.agent_id as %agent_id // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
// Other fields are omitted for simplicity
Inline [
conversations.id, conversations.ticket_id, conversations.contact_id, conversations.agent_id
1, 1, 2, 2
2, 1, 1, 2
3, 2, 3, 1
4, 4, 2, 3
];
[contacts]:
Load
contacts.id,
contacts.id as %contact_id // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
// Other fields are omitted for simplicity
Inline [
contacts.id
1,
2,
3
];
[agents]:
Load
agents.id,
agents.id as %agent_id // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
// Other fields are omitted for simplicity
Inline [
agents.id
1,
2,
3
];
Now the synthetic key will look like this:
$Syn 1 = %ticket_id+%contact_id+%agent_id
So, keys %ticket_id, %contact_id and %agent_id will be used only for relationships and nothing more. They should not be used as dimensions or for measurements on visualizations. For example, you would use tickets.id as the dimension (not %ticket_id). Or, if you want to count tickets: Count([tickets.id]) (not Count([%ticket_id])).