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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
BartVA
Creator
Creator

Timesheet data model (multiple many to many relations)

I have the following basic data.

Timesheet records:

Employee Duration (min) Product tags ID Customer Tags ID
AB 60    
AB 90 1  
AB 10 2 1
JR 50   2
JR 15 3  
JR 30 4 3

 

Product tags:

Product tags ID Product ID
1 101
1 102
1 103
2 101
3 103
3 105
4 200
4 201
4 202
4 203

 

Customer tags:

Customer Tags ID Customer ID
1 1000
2 1000
2 1001
2 1002
3 1001
3 1003

 

I want to be able to report eg. on customer 1000 or on product 101 the sum of duration. If I just do a join (two joins actually), then the duration will multiply. Same problem if I load the tables separately and let Qlik do the relations (I think). How do I model this correctly? Any insights would be greatly appreciated!

Labels (2)
1 Solution

Accepted Solutions
Vegar
MVP
MVP

If you don't join then you will get the figures correct.

Aim for a data model like my image below.

Vegar_0-1722934633221.png

Then you can get data like in my image below

Vegar_2-1722935105391.png

 

Selecting Customer 1000 will give 10+50= 60min. 

Selecting product 101 will give 10+90=100 min

----

[Timesheet records]:
LOAD Employee,
[Duration (min)],
[Product tags ID],
[Customer Tags ID]
FROM
[timesheet_concept.xlsx]
(ooxml, embedded labels, table is Sheet1);

[Product tags]:
LOAD
[Product tags ID1] as [Product tags ID],
[Product ID]

FROM
[timesheet_concept.xlsx]
(ooxml, embedded labels, table is Sheet1)
WHERE Exists([Product tags ID], [Product tags ID1])
;
[Customer tags]:
LOAD
[Customer Tags ID1] as [Customer Tags ID],
[Customer ID]
FROM
[timesheet_concept.xlsx]
(ooxml, embedded labels, table is Sheet1)
WHERE Exists([Customer Tags ID], [Customer Tags ID1]);

 

View solution in original post

2 Replies
Vegar
MVP
MVP

If you don't join then you will get the figures correct.

Aim for a data model like my image below.

Vegar_0-1722934633221.png

Then you can get data like in my image below

Vegar_2-1722935105391.png

 

Selecting Customer 1000 will give 10+50= 60min. 

Selecting product 101 will give 10+90=100 min

----

[Timesheet records]:
LOAD Employee,
[Duration (min)],
[Product tags ID],
[Customer Tags ID]
FROM
[timesheet_concept.xlsx]
(ooxml, embedded labels, table is Sheet1);

[Product tags]:
LOAD
[Product tags ID1] as [Product tags ID],
[Product ID]

FROM
[timesheet_concept.xlsx]
(ooxml, embedded labels, table is Sheet1)
WHERE Exists([Product tags ID], [Product tags ID1])
;
[Customer tags]:
LOAD
[Customer Tags ID1] as [Customer Tags ID],
[Customer ID]
FROM
[timesheet_concept.xlsx]
(ooxml, embedded labels, table is Sheet1)
WHERE Exists([Customer Tags ID], [Customer Tags ID1]);

 

BartVA
Creator
Creator
Author

Great, thanks!