Forum Discussion
Calculating Previous Values
- Anonymous4 years ago
Would something like this serve? I am assuming that the source data has a [Fiscal Week Ends] column, not a hire date.
Last 2 Weeks New =
var currentweek = [Fiscal Week Num]var previousweek = [Fiscal Week Num]-1
var currentweekhires =
CALCULATE(
SUM(
'Terms & Hires SQL'[Net Hires]),
[Fiscal Week End]=currentweekvar previousweekhires =
CALCULATE(
SUM(
'Terms & Hires SQL'[Net Hires]),
[Fiscal Week End]=previousweekreturn
currentweekhires+previousweekhires
Would something like this serve? I am assuming that the source data has a [Fiscal Week Ends] column, not a hire date.
Last 2 Weeks New =
var currentweek = [Fiscal Week Num]
var previousweek = [Fiscal Week Num]-1
var currentweekhires =
CALCULATE(
SUM(
'Terms & Hires SQL'[Net Hires]),
[Fiscal Week End]=currentweek
var previousweekhires =
CALCULATE(
SUM(
'Terms & Hires SQL'[Net Hires]),
[Fiscal Week End]=previousweek
return
currentweekhires+previousweekhires
That didn't work even when I found the columns....
- Anonymous4 years agoNot applicable
Hi,
I just realised I may be an idiot; you're after a calculated column, not a measure, right? In which case the following may not be relevant.
The DAX wasn't exact. If your source data has the week they occurred in as a column name, you can use that directly. If not, and you have some sort of date table, you may need to use the week number that is reference from that table.
You will need the table name e.g.
'Terms & Hires SQL'[Fiscal Week Ends]=currentweek
- Anonymous4 years agoNot applicable
My calculated column DAX is rusty, but here's a basic measure that'll do the job
LAST2WEEKSm =var currentweek = max(Table1[Fiscal Week Number])var previousweek = currentweek-1var currentweeknethires =CALCULATE(SUM(Table1[Net Hires]),Table1[Fiscal Week Number]=currentweek)var previousweeknethires =CALCULATE(SUM(Table1[Net Hires]),Table1[Fiscal Week Number]=previousweek)returncurrentweeknethires+previousweeknethires- Anonymous4 years agoNot applicable
Close? Because fiscal weeks differ from actual week numbers, for example, last week was Fiscal Week # 52 of 2021 and this week is Fiscal Week # 1 of 2022.
So there will be a break in count, even though the dates on which fiscal weeks are consecutive...
For example:
Fiscal Week 50 of 2021
Fiscal Week 51 of 2021
Fiscal Week 52 of 2021
Fiscal Week 1 of 2022
I don't think that week number is a good value to use, I changed it Fiscal Week End Date in hopes that it would just work but it did not.