Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Basis on below data I want to add a calculated column with Week Description
I've done it in excel by typing it manually.
Also my week is starting from Thursday and ends on Wednesday hence I've Used this function to get the weekday
WEEKDAY('Calendar'[date],14)
Requesting you to help me with a dax code which can be used to create a new calculated column with week information as shown below in third column.
The logic would be : If the date is current week then the value will be "This Week" else if the date is in last week then "This Week -1" else if the date is in last to last week then "This Week - 2" and so on.
Date | Weekday | WeekDesc |
01-12-2021 | 7 | This Week -3 |
02-12-2021 | 1 | This Week -2 |
03-12-2021 | 2 | This Week -2 |
04-12-2021 | 3 | This Week -2 |
05-12-2021 | 4 | This Week -2 |
06-12-2021 | 5 | This Week -2 |
07-12-2021 | 6 | This Week -2 |
08-12-2021 | 7 | This Week -2 |
09-12-2021 | 1 | This Week -1 |
10-12-2021 | 2 | This Week -1 |
11-12-2021 | 3 | This Week -1 |
12-12-2021 | 4 | This Week -1 |
13-12-2021 | 5 | This Week -1 |
14-12-2021 | 6 | This Week -1 |
15-12-2021 | 7 | This Week -1 |
16-12-2021 | 1 | This Week |
17-12-2021 | 2 | This Week |
18-12-2021 | 3 | This Week |
19-12-2021 | 4 | This Week |
20-12-2021 | 5 | This Week |
21-12-2021 | 6 | This Week |
Solved! Go to Solution.
Hi @Anonymous
Try this code to add a new column:
WeekDesc =
Var _A = WEEKNUM(today(),14)
Var _B = WEEKNUM([Date],14)
Var _C = _B-_A
return
if(_B=_A,"This Week","This Week" & _C)
output:
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: www.linkedin.com/in/vahid-dm/
Hi @Anonymous
Try this code to add a new column:
WeekDesc =
Var _A = WEEKNUM(today(),14)
Var _B = WEEKNUM([Date],14)
Var _C = _B-_A
return
if(_B=_A,"This Week","This Week" & _C)
output:
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: www.linkedin.com/in/vahid-dm/
Hi,
Like Syk mentioned you can use datediff. Additionally you can combine it with concatenate to get the exact result you described:
Proud to be a Super User!
The datediff function should work for you! Try this out for creating a new column with dax
WeekDiff =
DATEDIFF(today(),'Table'[Date],WEEK)
Check out the July 2025 Power BI update to learn about new features.
User | Count |
---|---|
23 | |
8 | |
7 | |
6 | |
6 |
User | Count |
---|---|
28 | |
12 | |
10 | |
10 | |
6 |