Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
mbahonen
Helper II
Helper II

Calculate Last 4 Weeks SUM in calculated column in a daily record table

Hello,

 

I'm sure I've over-complicated this, but I'm a little stuck with something. I have a table with employee records. Each employee has daily records for the past year (so each week has 7 records per employee). I have a column 'DailyDetails'[Summary] that is either a 1 or 0 based on some other criteria, but only applies that on Day 1 of each week. 

 

I need to SUM that column 'DailyDetails'[Summary] for each employee going back 4 weeks at a time. I can do this easily enough in a measure, but I need to be able to filter on this value, so I am trying to create it as a calculated column, but I keep getting circular reference errors. 

 

Yes, I have a date table. 

 

Sample data below:

 

This sample is only for one Employee ID number (1), but imagine thousands of ID's with their own records on the same table. I need a new column (not measure) that calculates the last 4 weeks of the [Summary] column on the first day of the week for each employee ID, but that ignores the 5th week (so excluding WeekNum 39).

 

I'd expect the below total applied to Week 1 of each Week in WeekNum 43 = 4, but WeekNum 42 = 3

 

I may need to filter or group by one or two other columns as well (to exclude the row when it meets certain criteria).

 

Thanks in advance!


TableName = 'DailyDetails'

WeekNumIDStart of WeekDateDay of WeekSummary
43110/22/202310/28/202370
43110/22/202310/27/202360
43110/22/202310/26/202350
43110/22/202310/25/202340
43110/22/202310/24/202330
43110/22/202310/23/202320
43110/22/202310/22/202311
42110/15/202310/21/202370
42110/15/202310/20/202360
42110/15/202310/19/202350
42110/15/202310/18/202340
42110/15/202310/17/202330
42110/15/202310/16/202320
42110/15/202310/15/202311
41110/8/202310/28/202370
41110/8/202310/27/202360
41110/8/202310/26/202350
41110/8/202310/25/202340
41110/8/202310/24/202330
41110/8/202310/23/202320
41110/8/202310/22/202311
40110/1/202310/7/202370
40110/1/202310/6/202360
40110/1/202310/5/202350
40110/1/202310/4/202340
40110/1/202310/3/202330
40110/1/202310/2/202320
40110/1/202310/1/202311
3919/24/20239/30/202370
3919/24/20239/29/202360
3919/24/20239/28/202350
3919/24/20239/27/202340
3919/24/20239/26/202330
3919/24/20239/25/202320
3919/24/20239/24/202310
4 REPLIES 4
lbendlin
Super User
Super User

 going back 4 weeks

including the current day?  full weeks?  or 28 days?

 

I'd expect the below total applied to Week 1 of each Week in WeekNum 43 = 4, but WeekNum 42 = 3

what is "Week 1 of each Week" ?

Week is determined by the Start of Week Date which is a field in our data and how our data is joined to our Calendar table. Its the most important aspect of this model. I have it in my sample data for that reason. 

and how our data is joined to our Calendar table.

Usually Calendar tables are joining to the fact tables via the date column rather than the aggregate (start of week). 

I'm aware of that. I actually think I misspoke. It is joined via date. Its just not usually relevant for this report. 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.