dlrosencrans
New Member
- Joined
- Apr 27, 2017
- Messages
- 4
Hoping someone has a number of ideas or a solution.
The requirement I have is to calculate a weekly average from a daily max transaction calculation for each day.
The following measures are working:
MaxTrans:=MAX(TransactionTable[Transactions])
MaxTransOnDay:=MAXX(VALUES(DimDate[Date]),[MaxTrans])
MaxTransOnCurrentWeek:=CALCULATE([MaxTrans],FILTER(All(DimDate), DimDate[WeekOfYearNumber] = MIN(DimDate[WeekOfYearNumber])))
A sample of the transaction table looks like:
[TABLE="width: 500"]
<tbody>[TR]
[TD]User[/TD]
[TD]DateTime[/TD]
[TD]Transactions[/TD]
[/TR]
[TR]
[TD]G1[/TD]
[TD]4/25/2017 9:00:00 AM[/TD]
[TD]30[/TD]
[/TR]
[TR]
[TD]G2[/TD]
[TD]4/25/2017 9:00:00 AM[/TD]
[TD]45[/TD]
[/TR]
[TR]
[TD]G1[/TD]
[TD]4/25/2017 9:15:00 AM[/TD]
[TD]40[/TD]
[/TR]
[TR]
[TD]G1[/TD]
[TD]4/25/2017 10:00:00 AM[/TD]
[TD]33[/TD]
[/TR]
[TR]
[TD]G2[/TD]
[TD]4/26/2017 9:00:00 AM[/TD]
[TD]39[/TD]
[/TR]
[TR]
[TD]G1[/TD]
[TD]4/26/2017 11:00:00 AM[/TD]
[TD]18[/TD]
[/TR]
</tbody>[/TABLE]
The Pivot looks like: Filtering User, Week, and Day (M-F)
[TABLE="width: 500"]
<tbody>[TR]
[TD]User[/TD]
[TD]Date[/TD]
[TD]MaxTransOnDay[/TD]
[TD]MaxTransOnWeek[/TD]
[/TR]
[TR]
[TD]G1[/TD]
[TD]4/25/2017[/TD]
[TD]40[/TD]
[TD]40[/TD]
[/TR]
[TR]
[TD]G1[/TD]
[TD]4/26/2017[/TD]
[TD]18[/TD]
[TD]40[/TD]
[/TR]
</tbody>[/TABLE]
What I am struggling with is the MaxAvgWeek:
[TABLE="width: 500"]
<tbody>[TR]
[TD]User[/TD]
[TD]Date[/TD]
[TD]MaxTransOnDay[/TD]
[TD]MaxTransOnWeek[/TD]
[TD]MaxAvgWeek[/TD]
[/TR]
[TR]
[TD]G1[/TD]
[TD]4/25/2017[/TD]
[TD]40[/TD]
[TD]40[/TD]
[TD]29[/TD]
[/TR]
[TR]
[TD]G1[/TD]
[TD]4/26/2017[/TD]
[TD]18[/TD]
[TD]40[/TD]
[TD]29[/TD]
[/TR]
</tbody>[/TABLE]
[FONT="]MAxAvgWeek:=CALCULATE(AVERAGEX(Transactions,[MaxTransDay]),FIL[/FONT]<wbr style="box-sizing: inherit; color: rgb(0, 0, 0); font-family: "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif; font-size: medium;">[FONT="]TER(ALL(Transactions),Transactions[WeekNum]=MAX(D[/FONT]<wbr style="box-sizing: inherit; color: rgb(0, 0, 0); font-family: "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif; font-size: medium;">[FONT="]ate[WeekNum])))[/FONT]
Thanks!
The requirement I have is to calculate a weekly average from a daily max transaction calculation for each day.
The following measures are working:
MaxTrans:=MAX(TransactionTable[Transactions])
MaxTransOnDay:=MAXX(VALUES(DimDate[Date]),[MaxTrans])
MaxTransOnCurrentWeek:=CALCULATE([MaxTrans],FILTER(All(DimDate), DimDate[WeekOfYearNumber] = MIN(DimDate[WeekOfYearNumber])))
A sample of the transaction table looks like:
[TABLE="width: 500"]
<tbody>[TR]
[TD]User[/TD]
[TD]DateTime[/TD]
[TD]Transactions[/TD]
[/TR]
[TR]
[TD]G1[/TD]
[TD]4/25/2017 9:00:00 AM[/TD]
[TD]30[/TD]
[/TR]
[TR]
[TD]G2[/TD]
[TD]4/25/2017 9:00:00 AM[/TD]
[TD]45[/TD]
[/TR]
[TR]
[TD]G1[/TD]
[TD]4/25/2017 9:15:00 AM[/TD]
[TD]40[/TD]
[/TR]
[TR]
[TD]G1[/TD]
[TD]4/25/2017 10:00:00 AM[/TD]
[TD]33[/TD]
[/TR]
[TR]
[TD]G2[/TD]
[TD]4/26/2017 9:00:00 AM[/TD]
[TD]39[/TD]
[/TR]
[TR]
[TD]G1[/TD]
[TD]4/26/2017 11:00:00 AM[/TD]
[TD]18[/TD]
[/TR]
</tbody>[/TABLE]
The Pivot looks like: Filtering User, Week, and Day (M-F)
[TABLE="width: 500"]
<tbody>[TR]
[TD]User[/TD]
[TD]Date[/TD]
[TD]MaxTransOnDay[/TD]
[TD]MaxTransOnWeek[/TD]
[/TR]
[TR]
[TD]G1[/TD]
[TD]4/25/2017[/TD]
[TD]40[/TD]
[TD]40[/TD]
[/TR]
[TR]
[TD]G1[/TD]
[TD]4/26/2017[/TD]
[TD]18[/TD]
[TD]40[/TD]
[/TR]
</tbody>[/TABLE]
What I am struggling with is the MaxAvgWeek:
[TABLE="width: 500"]
<tbody>[TR]
[TD]User[/TD]
[TD]Date[/TD]
[TD]MaxTransOnDay[/TD]
[TD]MaxTransOnWeek[/TD]
[TD]MaxAvgWeek[/TD]
[/TR]
[TR]
[TD]G1[/TD]
[TD]4/25/2017[/TD]
[TD]40[/TD]
[TD]40[/TD]
[TD]29[/TD]
[/TR]
[TR]
[TD]G1[/TD]
[TD]4/26/2017[/TD]
[TD]18[/TD]
[TD]40[/TD]
[TD]29[/TD]
[/TR]
</tbody>[/TABLE]
[FONT="]MAxAvgWeek:=CALCULATE(AVERAGEX(Transactions,[MaxTransDay]),FIL[/FONT]<wbr style="box-sizing: inherit; color: rgb(0, 0, 0); font-family: "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif; font-size: medium;">[FONT="]TER(ALL(Transactions),Transactions[WeekNum]=MAX(D[/FONT]<wbr style="box-sizing: inherit; color: rgb(0, 0, 0); font-family: "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif; font-size: medium;">[FONT="]ate[WeekNum])))[/FONT]
Thanks!