Forum Discussion
Anonymous
1 year agoNot applicable
Calculating Spend Last week
Hi there, please can anyone help. I am trying to create a measure calculating Spend LW. The issue is my stakeholders want it in such a way that they can select multiple weekstart dates and the Spend ...
- 1 year ago
First create a date table and mark it as a date table. Create a relationship from 'Date'[Date] to your 'Test'[Calendar Date] and then you can create a measure like
Spend Last Week = VAR EndDate = MIN('Date'[Date]) VAR NumSelected = COUNTROWS(VALUES('Date'[W / C])) VAR StartDate = EndDate - (7 * NumSelected) VAR DatesToUse = DATESBETWEEN( 'Date'[Date], StartDate, EndDate - 1 ) VAR Result = CALCULATE( SUM('TEST'[SPEND]), DatesToUse ) RETURN ResultSee the attached PBIX.
Anonymous
1 year agoNot applicable
Thanks for your prompt response but it is not calculating the figures correctly. If I select 13 Oct and 6th Oct, the values are as follows:
If I selected 20th and 27th Oct, then the Spend LW column should give me exactly the figures above but it is giving me :
johnt75
1 year agoSuper User
I think you're still using the [Spend LW] measure, not the [Spend Last Week] measure which uses the code I wrote. Check Duplicate of Page 1 in the PBIX