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.
Last 2 Weeks new =
Solved! Go to Solution.
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
Hi @Anonymous ,
Message 11 works well. Please try to create a similar DAX formula.
If you want to calculate with consecutive "week", you need to first create the year week column, then sort it with rankx function, and then use [sort] to represent the week based on the formula.
Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
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....
My calculated column DAX is rusty, but here's a basic measure that'll do the job
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.
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
@Anonymous Could you please provide the output you want from your measure as it may not be clear exactly what you are trying to achieve? What is the output you want for the Last 2 Weeks New column in your image?
Thanks heaps,
Theo
If I have posted a response that resolves your question, please accept it as a solution to formally close the post.
Also, if you are as passionate about Power BI, DAX and data as I am, please feel free to reach out if you have any questions, queries, or if you simply want to connect and talk to another data geek!
Want to connect?www.linkedin.com/in/theoconias
A sum of net hires for the past two weeks and it should be rolling...
Starting at fiscal week 48
Fiscal week 49 = sum of net hires for week 48
Fiscal week 50 = sum of net hires for week 49 and 48
Fiscal week 51 = sum of net hires for week 49 and 50
Fiscal week 52 = sum of net hires for week 50 and 51
And so on
Fiscal week end date should be used as an identifier since it contains an actual date
Dataset contains other columns that will be used as filters, location for example, so the values in the measure should change with the filters.
Hi @Anonymous,
You can use the following and adapt it your tables / column names:
14 Days =
VAR _1 = LASTDATE ( 'Table'[Date] ) // This is the date in your fact table
VAR _2 = _1 - 14 // represents the 14 days in the respective fortnight
RETURN
CALCULATE ( SUM ('Table'[Amount] ) , FILTER ( ALL ( 'Date') , AND ( 'Date'[Date] > _2 , 'Date'[Date] <= _1 ) ) )
The above assumes you have a Date / Calendar table. If not, please adjust the 'Date' to the respective date column in your fact table.
Hope this helps 🙂
Theo
If I have posted a response that resolves your question, please accept it as a solution to formally close the post.
Also, if you are as passionate about Power BI, DAX and data as I am, please feel free to reach out if you have any questions, queries, or if you simply want to connect and talk to another data geek!
Want to connect?www.linkedin.com/in/theoconias
this is giving me the same value as net hires....
Sorry mate, just change VAR _1 to the following:
VAR _1 = LASTDATE ( 'Table'[Date] ) - 7
So the whole measure will be:
14 Days =
VAR _1 = LASTDATE ( 'Table'[Date] ) - 7 // This is the date in your fact table
VAR _2 = _1 - 14 // represents the 14 days in the respective fortnight
RETURN
CALCULATE ( SUM ('Table'[Amount] ) , FILTER ( ALL ( 'Date') , AND ( 'Date'[Date] > _2 , 'Date'[Date] <= _1 ) ) )
If I have posted a response that resolves your question, please accept it as a solution to formally close the post.
Also, if you are as passionate about Power BI, DAX and data as I am, please feel free to reach out if you have any questions, queries, or if you simply want to connect and talk to another data geek!
Want to connect?www.linkedin.com/in/theoconias
Now it's blank...I am trying to tinker with it myself too by the way....
@Anonymous try the below:
14 Days =
VAR_1 = LASTDATE ( 'Terms & Hires SQL'[Fiscal Week Ends] ) - 7
VAR_2 = _1 - 14
RETURN
CALCULATE ( SUM ('Terms & Hires SQL'[Net Hires] ) , FILTER ( ALL ( 'Terms & Hires SQL'[Fiscal Week Ends]) , AND ( 'Terms & Hires SQL'[Fiscal Week Ends] > _2 , 'Terms & Hires SQL'[Fiscal Week Ends] <= _1 ) ) )
If I have posted a response that resolves your question, please accept it as a solution to formally close the post.
Also, if you are as passionate about Power BI, DAX and data as I am, please feel free to reach out if you have any questions, queries, or if you simply want to connect and talk to another data geek!
Want to connect?www.linkedin.com/in/theoconias
It was giving me errors so I modified it (bottom snip)
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
105 | |
96 | |
79 | |
67 | |
62 |
User | Count |
---|---|
137 | |
106 | |
104 | |
81 | |
63 |