Averaging a product of values

masplin

Active Member
Joined
May 10, 2010
Messages
413
Hi. looknig for them ost efficient way to do the following. I have users carrying out spending transactions and want to know the average no of spends per user in different catagories e.g. male/female. I can think of 2 ways:
  1. In powerpivot window on the user table do SpendCount=CALCULATE(counta(users[transactions]),filter(transactions,transaction[transaction]="spend"))
Then in my pivot table do an average of Spendcount.
2. Create a pivottable measure AvSpendcount=CALCULATE(counta(users[transactions]),filter(transactions,transaction[transaction]="spend"))/
CALCULATE(DISTINCTCOUNT(Users[UserID]),filter(transactions,transaction[transaction]="spend"))

2nd one has the advantage of not creating yet another column of data in my model but means I can't just reuse Spendcount in other calculations. Is there any other smart way tod this sort of thing as doing it a lot i.e. user aveage of some calculation?

Thanks

Mike
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
If you do this with a calculated column, then you will not be able to perform calculations in different time periods, which is a pity. Your SpendCount is computed per user and fixed in the database... I would not do this way. I have not tried this code, but this might be a simple idea:

AVERAGEX (Users, CALCULATE (COUNTROWS (Transactions), Transactions[Transaction] = "Spend"))

You need to decide how to handle users who never bought anything, do they count as zero or do you want to ignore them?

Alberto
SQLBI
 
Upvote 0

Forum statistics

Threads
1,223,935
Messages
6,175,497
Members
452,649
Latest member
mr_bhavesh

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top