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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Fabric Monthly Update - May 2024

Check out the May 2024 Fabric update to learn about new features.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.