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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
djaaiin93
Frequent Visitor

Comparing sales for customer and sales rep / Comparing one value by two dimensions

Hello,


I have a rather peculiar report that I'm stuck on. As you can see, I'm not even sure how to title this. This is what my sales fact table looks like. I already have dim tables for customers and sales reps with the relationships set up and working fine. 

CustomerSales RepSale DateSales Amount
AX1 Jan 2020500
BXX1 Jan 2020600
CY1 Jan 2020200
DYY1 Jan 2020300

 

Sales Reps X and XX sell products to customers A and B. Sales Rep Y collects stock from A and sells to customer C; Sales Rep YY collects stock from B and sells to D. 

 

I would like to compare customers A and B purchases with sales of reps Y and YY. 

 

Customer A500Sales Rep Y200200/500 = 40%
Customer B600Sales Rep YY300300/600 = 50%

 

How would I do this? Would I need to create additional tables to what I already have? I'm also not sure what visual(s) would be a good fit for this situation.

 

Thank you.

1 ACCEPTED SOLUTION
v-rzhou-msft
Community Support
Community Support

Hi @djaaiin93 

I think you need to build a relationship table to show where the stock from and where the stock to go. This is important, we need a table with this information to let Power BI konw when we calculate the percentage.

I think you can try to add Sales ID in your Sales Fact table and build a New table by Sales ID.

Sales Table:

1.png

Relationship Table:

2.png

Relate two tables by SalesID (Sale Table) and From Sales ID(Relationship Table)

Build measures:

Sale stock amount = 
CALCULATE(SUM(Sales[Sales Amount]),FILTER(ALL(Sales),Sales[SalesID] = MAX(Relationship[To Sales ID])))
Percentage = 
DIVIDE([Sale stock amount],SUM(Sales[Sales Amount]))

Result:

1.png

Best Regards,

Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. 

View solution in original post

1 REPLY 1
v-rzhou-msft
Community Support
Community Support

Hi @djaaiin93 

I think you need to build a relationship table to show where the stock from and where the stock to go. This is important, we need a table with this information to let Power BI konw when we calculate the percentage.

I think you can try to add Sales ID in your Sales Fact table and build a New table by Sales ID.

Sales Table:

1.png

Relationship Table:

2.png

Relate two tables by SalesID (Sale Table) and From Sales ID(Relationship Table)

Build measures:

Sale stock amount = 
CALCULATE(SUM(Sales[Sales Amount]),FILTER(ALL(Sales),Sales[SalesID] = MAX(Relationship[To Sales ID])))
Percentage = 
DIVIDE([Sale stock amount],SUM(Sales[Sales Amount]))

Result:

1.png

Best Regards,

Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.