Forum Discussion
Cummulative Previuos Year and Current
HI good day, can anyone pls help me correct my calculated column, on my table i have year 2024 and 2025 but when i used my below code the 2024 also end the calculation this week. it should apply only on the current year and week.
DESIRED OUTPUT
Thank you
You're very close! The issue lies in the condition:
IF(WeeklyPlan[Used_FinalWKno.] <= WEEKNUM(TODAY()), ...)
This limits calculation only by Used_FinalWKno. without checking if it's the current year. So for prior years (e.g., 2024), it still applies the current week's number as a limit. To fix it, include the current year check.
✅ Corrected Calculated Column
Cum_Earned = VAR CurrentWeek = WEEKNUM(TODAY()) VAR CurrentYear = YEAR(TODAY()) VAR RowWeek = 'WeeklyPlan'[Used_FinalWKno.] VAR RowYear = 'WeeklyPlan'[Used_FinalYr] VAR FilteredTable = FILTER( 'WeeklyPlan', 'WeeklyPlan'[Used_FinalWKno.] <= RowWeek && 'WeeklyPlan'[Used_FinalYr] = RowYear ) RETURN IF( RowYear < CurrentYear || (RowYear = CurrentYear && RowWeek <= CurrentWeek), CALCULATE(SUM('WeeklyPlan'[EarnedHrs]), FilteredTable) )🔎 Explanation:
- RowYear < CurrentYear: Always allow past years to show full cumulative results.
- RowYear = CurrentYear && RowWeek <= CurrentWeek: Limit current year to current week only.
- This ensures 2024’s full data is preserved while limiting 2025 to the current week.
Try refreshing the visual to confirm filters apply correctly!
✔️ If my message helped solve your issue, please mark it as Resolved!
👍 If it was helpful, consider giving it a Kudos!
2 Replies
- SolomonovAnton
Super User
You're very close! The issue lies in the condition:
IF(WeeklyPlan[Used_FinalWKno.] <= WEEKNUM(TODAY()), ...)
This limits calculation only by Used_FinalWKno. without checking if it's the current year. So for prior years (e.g., 2024), it still applies the current week's number as a limit. To fix it, include the current year check.
✅ Corrected Calculated Column
Cum_Earned = VAR CurrentWeek = WEEKNUM(TODAY()) VAR CurrentYear = YEAR(TODAY()) VAR RowWeek = 'WeeklyPlan'[Used_FinalWKno.] VAR RowYear = 'WeeklyPlan'[Used_FinalYr] VAR FilteredTable = FILTER( 'WeeklyPlan', 'WeeklyPlan'[Used_FinalWKno.] <= RowWeek && 'WeeklyPlan'[Used_FinalYr] = RowYear ) RETURN IF( RowYear < CurrentYear || (RowYear = CurrentYear && RowWeek <= CurrentWeek), CALCULATE(SUM('WeeklyPlan'[EarnedHrs]), FilteredTable) )🔎 Explanation:
- RowYear < CurrentYear: Always allow past years to show full cumulative results.
- RowYear = CurrentYear && RowWeek <= CurrentWeek: Limit current year to current week only.
- This ensures 2024’s full data is preserved while limiting 2025 to the current week.
Try refreshing the visual to confirm filters apply correctly!
✔️ If my message helped solve your issue, please mark it as Resolved!
👍 If it was helpful, consider giving it a Kudos!
- AllanBerces
Post Prodigy
Hi SolomonovAnton thank you very much for the reply and for the info, working as i need.