Forum Discussion
Help with relationship between tables
Dear community hope you can help me in my journey with power BI - From excel background I just built a whole dashboard but I have one issue which i dont know how easy is to resolve...
Problem: The problem I have is merging or showing data from one table (Calls table) into my fact/main table which is the Sales Table.
Definition of the tables:
There are two tables involved in the issue. Calls table which records all the Calls which are sales representative visit to a customer with a lot of details about the call (type of sales visit, customer, duration of the visit, product, customer, month, sales representative name, region etc).
The sales table/fact table contains our sales per month by customer, year, product and a lot bunch of other details.
Relationship between the tables: the current relationship between the two tables is a concatenate column I have built composed of the customer code, the year, the month and the product it is named: Combo_CE_YearMonth_SFEProduct. I built like old school excel, a unique identifier to be able to match both tables
The relationship is one to many, meaning that in the Sales table I only have 1 unique identifier in the Combo_CE_YearMonth_SFEProduct column and in the Calls table I might have a two calls that were to the same customer with the same unique identifier however the type of call might have been different for instance one call was to discuss a partnership and another call to show a product or could be that calls were on different dates. In the calls table I also have an activity ID which is a unique ID for the call only. Below you see roughly how my model is looking and all the tables involved
What I would like to do create some visuals and matrixes where I can see for a particular customer in a particular month a) how much sales of certain product was; and b) how many calls we did for that customer and that product or if we only did calls, then only show the calls but 0 sales.
BUT the problem is that in one month you might have zero sales (hence the Concatenate in the sales table doesn’t exist) but you did for example 20 calls. My report then is showing no sales and no calls.
Below is an easy way of looking into this from the raw data (pivoted in excel). I basically put together an example of one product where we had sales in different customers and only one of those customers happen to had a call as well (OOST Limburg Genk) so my power bi report only brings this 0.5 call but not for the AZ JAN PORTAELS customer.
Here is what I get on my power BI report, only 0.5. I would have liked to see also the AZ Jans portaels call of 0.83 but because we didn’t do any sales on that month I don’t get it.
Hope you can help me to resolve this in a practical way. I sense this could be resolved with merging tables etc but not sure
Big thanks!
PD: Please do not bother why a sales visit is 0.5 or 0.83, you could say shouldn’t it be counted as 1. Yes, but we apply certain criteria like duration, effectiveness etc to make be lower than 1.
It would be easier to correct if you could post the file, but I'm assuming it is not anonymized data.
From what I can see, if you delete the relationship between your Calls and Sales tables (because essentially they are both Fact tables) and instead create a 1 to many relationship between the Calls and Date/Customer tables, you should be able to create a matrix with
1. Date from date table
2. Customer from customer table
3. Measures - either from Measures Table or Fact tables respectively depending on how you set up measures in your model
Because the relationships have been estabilished with both Fact tables (Call and Sales) the measures should populate for each customer.
Hope this helps.
1 Reply
- sdrausNew Member
It would be easier to correct if you could post the file, but I'm assuming it is not anonymized data.
From what I can see, if you delete the relationship between your Calls and Sales tables (because essentially they are both Fact tables) and instead create a 1 to many relationship between the Calls and Date/Customer tables, you should be able to create a matrix with
1. Date from date table
2. Customer from customer table
3. Measures - either from Measures Table or Fact tables respectively depending on how you set up measures in your model
Because the relationships have been estabilished with both Fact tables (Call and Sales) the measures should populate for each customer.
Hope this helps.