Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
SBN
Contributor III
Contributor III

Single employee table multiple "roles" for an employee.

Hi there fellow Qlikkies,

I'm trying to figure out a way to accommodate a single "Employee" table in my data model and have different "roles" for the employees without duplicating the "Employee" table in separate "role" tables.

Attached is a demo app with a simplified version of a more difficult data model:

SBN_0-1700474782436.png

The data model has an "Orders" table which contains sales orders which contains a reference to SalesPerson to whom the value of the order is linked. And an Author who's registered the order.
It has a "Customer" table which holds customers with a AccountManager who's responsible for the customer.
And it has an "Employee" table which contains all the employee related information.
I've tried to connect this all together through a "Roles" table, but end up with the synthetic key and circular loop...;-)

Is it possible to have a single employee table for different roles in a data model?
If so can you help me out with suggestions or if you're willing to put in the effort remodel the data model in the example app?

Thanks in advance,

SBN

Labels (3)
1 Solution

Accepted Solutions
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

I took a crack a remodeling it like this (qvf attached). 

rwunderlich_0-1700501417077.png

rwunderlich_1-1700501494207.png

Downside is that you won't be able to easily show Customer + Account Manager Name for Customers who don't have Orders. 

-Rob
http://www.easyqlik.com
http://masterssummit.com
http://qlikviewcookbook.com

View solution in original post

10 Replies
vincent_ardiet_
Specialist
Specialist

You could try with a Roles table containing OrderID, EmployeeID, CustomerID, Role with this last field containing the value "SalesPerson" or "AccountManager".
You will of course have to remove CustomerID and SalesPersonID from table Orders and also AccountManagerID from Customers.

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

I took a crack a remodeling it like this (qvf attached). 

rwunderlich_0-1700501417077.png

rwunderlich_1-1700501494207.png

Downside is that you won't be able to easily show Customer + Account Manager Name for Customers who don't have Orders. 

-Rob
http://www.easyqlik.com
http://masterssummit.com
http://qlikviewcookbook.com

vincent_ardiet_
Specialist
Specialist

That's why I was suggesting to have the link with the customer in RoleLink, else you can't have an account manager without orders. 

SBN
Contributor III
Contributor III
Author

@vincent_ardiet_ & @rwunderlich,

Thank you both for your time and efforts to help me out with this subject. Really appreciate it!

I used a combination of both of your answers to set it up in the example app.
Now the resulting straight tables show the relationships between the different datasets and roles.

SBN_0-1700561126305.png

@rwunderlich uses the "only()" function in a measure for the customer "Account manager", the orders "Sales person" and order "Author" in order to show them in one line in a straight table.

Is there a possibility to turn these measures into dimensions to use them in selections?
I know you can create an aggregate dimension, but the selection would than be either on "Customer" or "Order" instead on the "Employee name"...😁

Or do you have to add them as a separate duplicated table per role of the "Employee" table in your data model?
And explain to the user of the dashboard that they need to switch selections based on the role they want to analyse?

Thanks again!!

SBN

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

You can turn them into Dimensions and control what field gets selected by what Field you use in the Aggr. 

=Aggr(only({<Role={'Author'}>}Name), Name)

https://qlikviewcookbook.com/2016/01/scoping-selections-with-aggr/

If you want to have a Dimension named "Author" and have the current selections show as "Author" I believe you will have to duplicate the Name field as Author either in the RoleLink or the Employee table.

-Rob

SBN
Contributor III
Contributor III
Author

Hi @rwunderlich ,

I just realized I forgot to thank you for your additional suggestion.
My apologies!
Thank you!

Kind regards,

SBN

SBN
Contributor III
Contributor III
Author

@rwunderlich and @vincent_ardiet_ ,

The combination of both of your suggestions has probably solved the challenge I had.
I created the "RoleLink" table.
That works like charm.
With regards to the dimensions I choose to use "If(Role="...", ...)" expressions.
Not the optimal solution I guess, because it adds a second selection "Role".
And might be a bit more confusing to the user.
On the other hand does the dashboard show the information related to that particular role of the employee.

Thanks again!

Kind regards,

SBN

P.S. Because both of your efforts helped me in the right direction who would like me to accept the solution of the other one? 😉

vincent_ardiet_
Specialist
Specialist

Good to know that it helped.
You could select both I think, else Rob deserves it more than me, I'm less than a Padawan compared to his Jedi master skills 🙂

SBN
Contributor III
Contributor III
Author

@vincent_ardiet_ 

Thanks, I will!
Your last sentence must be something from Star Wars. I recognize the "Jedi" part. The "Padawan" part doesn't ring a bell with me, sorry...😁