I have 8 tables with data of sold products. Each table is about a unique product. In Power BI, I want to create a matrix, containing the sold quantities (values) per product (rows), per month (columns), and the number of unique customers who bought the products.
Each of the 8 tables with the sales data has the following structure. So the App ID
is different for each table, but is constantly the same within a table. Example for a Cars
table:
Customer ID Month App ID
29273 2020-3 1
90283 2018-5 1
55824 2016-12 1
55824 2018-10 1
55824 2021-1 1
So, a bicycle table would have the same structure, but then the App ID
's would be, for example 2, in the entire table.
I have two tables that are connected with the 8 product tables in a one-to-many relationship. The Calendar
table based on the Month
column, and the App
table based on the App ID
column.
The table Calendar
:
Month
2015-1
2015-2
2015-3
2015-4
2015-5
...
...
The table Apps
:
ID Name
1 Cars
2 Bicycle
3 Scooter
4 ...
So, the structure is:
I created the Calendar
en Apps
tables so that I could use them for the matrix, but it doesn't work like I want so far. At the end, I want to create a matrix like this (where P
= the number of products sold, and C
= the number of customers in that month for that product):
Product 2015-1 2015-2 2015-3 2015-4 2015-5 ...
P C P C P C P C P C
Cars 3 2 5 5 7 6 2 1 4 2
Bicycle 11 9 17 14 5 5 4 4 8 6
Scooter ...
Skateboard ...
As mentioned, I made that Calendar
and App
table so that I can use the columns from it to fill the labels in the rows and columns. What I am unable to do is create such a 'general variable' of the number of products sold per product, and the number of customers associated with it.
Can someone explain to me how I can fill the matrix with the numbers of products (and customers) sold, so that the matrix looks like the one described above?