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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.