Forum Discussion
Categorical Rolling Average
- 6 years ago
t-dahen ,
ah missed that summarization of the sales per day needs to be done first. Adjusted! output is now as expected:Adjusted code:
_2_Measure_RunningAverageNameCategorySales = var _CTfilter = DATESINPERIOD('Date'[Date]; MIN('Date'[Date]);-7;DAY) var _CT = CALCULATETABLE(SUMMARIZE('Table';'Table'[Name];'Date'[Date];"sales"; CALCULATE(SUM('Table'[Sales]))) ;_CTfilter;ALLEXCEPT('Table';'Table'[Name];'Table'[Category])) return IF(NOT(ISBLANK(MIN('Table'[Sales]))); AVERAGEX(_CT;[sales]); BLANK())_1_Measure_AverageOfAverageRunningSalesinCat = var _sumtbl = CALCULATETABLE(SUMMARIZE('Table';'Table'[Name];'Date'[Date];'Table'[Category]; "runningsales"; [_2_Measure_RunningAverageNameCategorySales]);ALLEXCEPT('Table';'Date';'Table'[Category])) return AVERAGEX(_sumtbl; [runningsales])New file available here.
Hope we got it now?
Kind regards, Steve.
Thank you for the response,
I want to compare these two numbers NameRollAvg and CategoryRollAvg. Basically to see how did this Name compare to others in it's Category. Take for example, Bob's Sales for this week is 1 and Alice's Sales for this week is 14 and they are both Category A. If we did "average of sales per category" the CategoryRollAvg would be (1 + 14) / 7 = 2.14... However, what I would like to see is the average of all the NameRollAvg. [(1/7) + (14/7)] / 2 = 1.07...
Yeah, no, still not buying it. You already know that 14 is more than 1. Fudging the average in that way is not constructive IMHO.
- t-dahen6 years ago
Microsoft Employee
Why?
If one person sells a huge amount while every other person sells a small amount, I don't want this CategoryRollAvg to be greatly skewed by that. So, it may look like a lot of people are severely underperforming but in reality only one person is greatly performing . Again, I want to use these two metrics to compare one person to the rest of their peers. Unless I'm completely missing something math related...
Nonetheless, is this possible to implement?
- lbendlin6 years ago
Super User
Mathematically all you are doing is dividing the NameRollAvg by the count of names. What for?
- t-dahen6 years ago
Microsoft Employee
Dividing the Summation of all NamRollAvg by the number of names. I want to see on average how many sales/week per name in a category:
Name NameRollAvg Bob 4 Alice 5 Joe 6 All belonging to the same category... The people in this category have around 3 sales per week. I am running this average not on raw sales but the derived NameRollAvg