Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
B_Rax
Frequent Visitor

Relating Sales Table to Customer Assignments Across Three Fields

I'm currently expanding my existing data model to include a bit of an odd field. Currently, our sales data doesn't record the proper outside salesperson based on sales territory. Therefore, we assign salespeople based on a table Customer Assignments which lists customer numbers, their branch, their assigned employees, and the dates those employees were assigned/removed from that customer. This means to relate each sale to its salesperson we have to join on Customer Number, Date, and Branch.

 

Our sales data is sourced from a database that we only have read access to. The customer assignments table exists on a local server db. We do, however, have a linked connection to that database on the local server from which I attempted to join Sales to Customer Assignments, but it was much too slow.

 

My next attempt involved creating a compound key (CustomerAssignmentsID) on each table using Branch + Customer Number + Date. To facilitate this I used a query that returns the Customer Assignments table with a row for every date a salesperson was assigned to it since it was originally a date range across two columns. This obviously generates a very large assignment table. This implementation almost works, but its slow and I get strange results. For example, sales over the front counter do not have an outside salesperson assigned. Those rows should be blank for the salesperson column. I still want to see those rows so I have to select "Show items with no data". The rows appear, but their Sales fields like Price and Cost show blank. If I remove the salesperson column they show correctly again. 

 

Please advise me on this. If there is any more information I can provide let me know!

Here are some examples of my tables:

B_Rax_4-1714665765097.png

 

B_Rax_1-1714665127378.png

 

B_Rax_2-1714665137743.png

Customer Assignments modified for compound key:

B_Rax_3-1714665186978.png

 

Desired Results:

B_Rax_5-1714665800823.png

 

Here is my current model after my second attempt:

B_Rax_6-1714666124435.png

 

 

 

 

 

2 REPLIES 2
v-xuxinyi-msft
Community Support
Community Support

Hi @B_Rax 

 

Is there some kind of connection between the Date columns in the four tables you gave? Based on the sample data you have now provided, I don't think this can be accomplished.

 

Best Regards,
Yulia Xu

Thanks for the response. Using the modified Customer Assignments table in the second solution leads to relationships that look like this:
Calendar[Date] 1:* Sales[Date]
Sales[CustomerAssingmentsID] *:* CustomerAssigments[CustomerAssigmentsID] (CustomerAssignments Filters Sales)

The invoice date from Sales is part of the compound key CustomerAssignmentsID which relates to the compound key CustomerAssignmentsID in the Customer Assignments table which uses the modified assigned date. The excel example calculated the date as a string which is why it may not look like date is part of the compound key.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.