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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

How to Get Custom Week Desc in DAX

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.

DateWeekdayWeekDesc
01-12-20217This Week -3
02-12-20211This Week -2
03-12-20212This Week -2
04-12-20213This Week -2
05-12-20214This Week -2
06-12-20215This Week -2
07-12-20216This Week -2
08-12-20217This Week -2
09-12-20211This Week -1
10-12-20212This Week -1
11-12-20213This Week -1
12-12-20214This Week -1
13-12-20215This Week -1
14-12-20216This Week -1
15-12-20217This Week -1
16-12-20211This Week
17-12-20212This Week
18-12-20213This Week
19-12-20214This Week
20-12-20215This Week
21-12-20216This Week




1 ACCEPTED SOLUTION
VahidDM
Super User
Super User

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:

VahidDM_0-1640125399477.png

 

 

 

 

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/

 

 

View solution in original post

3 REPLIES 3
VahidDM
Super User
Super User

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:

VahidDM_0-1640125399477.png

 

 

 

 

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/

 

 

ValtteriN
Super User
Super User

Hi,

Like Syk mentioned you can use datediff. Additionally you can combine it with concatenate to get the exact result you described:

This week =
var TW = DATEDIFF(TODAY(),'Calendar'[Date],WEEK)
return
If(TW=0,"This week",CONCATENATE("This Week ",TW)

)
End result:
ValtteriN_0-1640123062180.png

 






Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Syk
Super User
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)

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.