I have a user request to calculate the totals for the recent week. We have the daily trend date every day. I created a var using =DayNumberOfWeek([Daily Trend Date]), then set a fjilter as 7, which gave me every weekending date, i.e. 5/9/10, 5/2/10, 4/25/10… but I only needed the latest weekending: 5/9/10
If I understand your requirements correctly, you have numbers for each day which you want to aggregate for the week. For example, figures for May 3rd to May 9th should appear under a heading of w/e May 9th.
Based on this assumption, you should create a local variable, let’s call it ‘Week Ending’ with the following code: =RelativeDate([Date];7-DayNumberOfWeek([Date]))
Using this object with the measure object will give you totals for the week
Hi - if you’ve got multiple weeks in your data then that probably won’t work as intended because it’s looking at every Monday, t,w,t,f,s, sunday. (So, if you’ve got a month to date report with 31 days of data in it it’ll treat every monday as being in the last week)…i think… it’s early.
Ideally, you should work to resolve this at universe level and create a flag against [Date] in there to determine if a date’s in the last week. Bring it in to the report and filter on it or perform calculations on it in a where clause. - Or if you’re building a report that’ll only be for the last 7 days - use it in your query criteria.
If you’re working at report level only: If your report runs on a monday morning for the prior week :
Create a variable that’s called [Last 7 Days Test]
=if(daysbetween([Date];currentdate())<=7;“Y”;“N”)
That gives you a Y against all dates in the prior week. You can then use that in where clauses or as a filter on a table to filter it by Y to show only dates for the prior week.
If your report runs Monday -Friday or Sunday and you want to identify the dates in the prior week Mon-Fri then you have to use LastDayofWeek() function to analyse the Sunday in the week of your Date field.