Hi all,
I am having trouble aggregating totals & averages correctly across two data sets. Here's an example:
I have two data sets. Data set one (from an excel sheet) records each sale. Eg:
Client Store Amount Group
Person 1 StoreA $5 Cards
Person 1 StoreB $8 Books
Person 1 StoreA $9 Wires
Person 1 StoreC $11 Stamps
Person 2 StoreB $6 Books
Person 2 StoreD $4 Books
Person 2 StoreE $12 Wires
Person 3 StoreB $8 Books
Person 3 StoreC $2 Cards
I have a second data set (client data) that has other information for each person which contains other information. I have a relationship between the data sets based on client number.
My problem:
I can calculate correctly within data set 1 the total sales by person by Group from my sales set:
Person 1
Cards $5
Books $8
Wires $9
Stamps $11
Person 2
Books $20
Wires $12
Person 3
Books $8
Cards $2
My problem is how to calculate average sales by group for every person in data set 2, where if someone doesn't have a purchase in a group the assumed purchase amount for that person should be $0, then I'd like to average all of these.
So end result looks like:
Averages by Group
Cards = (5+0+2)/3
Books = (8+20+8)/3
Wires = (9+12+0)/3
Stampes = (11+0+0)/3
Manually I've done this before by creating a calculation in datatable 1 for total, creating tableview by Group, exporting then putting this into my dataset2 (an excel sheet) manually, forcing a zero for clients without a purchase. However that seems silly.
I'd appreciate any thoughts on how to do this within powerbi (as this is just one simple example, I have a few other groups to do as well)
Thanks