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 September 15. Request your voucher.

Reply
medwards
Frequent Visitor

Nested if statement based on dates for New Column

Hope you can kindly assist. I'm trying to write a nested if statement for a new column I created, but I'm having trouble with the syntax. My new column is called "WEEK #" where it is the number of weeks after the start date (Jan 30, 2023).

 

WEEK # = IF(
'TABLE'[Completed Date] >= DATE(2023,1,30) AND <= DATE(2023,2,4),1,
(IF('TABLE'[Completed Date] >= DATE(2023,2,5) AND <= DATE(2023,2,11),2,
(IF('TABLE'[Completed Date] >= DATE(2023,2,12) AND <= DATE(2023,2,18)),3,
(IF('TABLE'[Completed Date] >= DATE(2023,2,19) AND <= DATE(2023,2,25)),4,
(IF('TABLE'[Completed Date] >= DATE(2023,2,26) AND <= DATE(2023,3,4)),5),
ELSE " ")))))
 
If there's an easier way to do this, I'm open to other ideas. Thanks!
1 ACCEPTED SOLUTION
Syk
Super User
Super User

Try using the datediff function instead... Something similar to this:

Weeks_After_Start_Date = DATEDIFF("1/30/2023", 'Table'[Completed Date], WEEK)

View solution in original post

2 REPLIES 2
medwards
Frequent Visitor

Thank you! That is so much easier 🙂

Syk
Super User
Super User

Try using the datediff function instead... Something similar to this:

Weeks_After_Start_Date = DATEDIFF("1/30/2023", 'Table'[Completed Date], WEEK)

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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