Forum Discussion
Last 2 weeks sales
- 10 years ago
Hi,
For example, Your sales table is like below:
You can create a measure to calculate the sum of salesAmount of weeknum 6 and 7:
last2WeeksAmount = CALCULATE(sumx(sales, sales[salesAmount]),Filter(ALL(sales), sales[weeknum]=max(sales[weeknum])-1 || sales[weeknum] = MAX(sales[weeknum])-2))
Best Regards
Alex
You need a calendar table with a unique Week ID column. Read about that here
http://exceleratorbi.com.au/power-pivot-calendar-tables/
As as long as you have a unique week ID column, you can write a formula like this
Last 2 Weeks :=
CALCULATE (
[Total Sales],
FILTER (
ALL ( Calendar ),
Calendar[WeekID] >= MAX ( Calendar[WeekID] ) -1
&& Calendar[WeekID] <= MAX ( Calendar[WeekID] )
)
)
- sidds_sriv10 years agoRegular Visitor
Thanks Matt , it worked....
- uksrik8 years agoRegular Visitor
Awsome, That was a cool trick Matt!!!
I used used your logic to calculate Current Week Measure:
CALCULATE(
'TableQuery'[Sales US($)],
FILTER (
ALL ( 'Sales US($)' ),
[TableQuery] >= MAX ( 'TableQuery'[Fiscal Year and Week] )
))