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

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.

Reply
Anonymous
Not applicable

Determine if two different dates (from two different columns) are in the same week

My scenario is pretty simple:    If the dates below fall within the same week, then "0", if not, then the number of DAYS between the two dates.   Due Date is connected to my date table.  

 

I have two dates for this that are relevant.    Due Date   &   Projected Date

 

My current code only looks at if the dates are exactly the same.   What I need is to determine whether they are just in the same Week or not.     In the example below, March 01  and  March 03 are within the same week, so the result should be "Yes".  

 

Is in same Week =
VAR _DueDateWeek = SalesOrdersALL[Due Date]
VAR _ProjectedWeek = SalesOrdersALL[ProjectedDate].[Date]

RETURN
IF(_DueDateWeek = _ProjectedWeek,"Yes","No")

 

texmexdragon_0-1646263084102.png

 

1 ACCEPTED SOLUTION
Vera_33
Resident Rockstar
Resident Rockstar

Hi @Anonymous 

 

Are you doing a DAX Calculated column or measure? Use WEEKNUM?

Vera_33_0-1646266974816.png

Is in same Week = 
VAR CurDueWeek=WEEKNUM( 'Table'[Due Date])
VAR CurProjectedWeek=WEEKNUM('Table'[ProjectedDate])
RETURN
IF(CurDueWeek=CurProjectedWeek,"Yes","No")

 

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

I am using a column so it looks like this should work!

Vera_33
Resident Rockstar
Resident Rockstar

Hi @Anonymous 

 

Are you doing a DAX Calculated column or measure? Use WEEKNUM?

Vera_33_0-1646266974816.png

Is in same Week = 
VAR CurDueWeek=WEEKNUM( 'Table'[Due Date])
VAR CurProjectedWeek=WEEKNUM('Table'[ProjectedDate])
RETURN
IF(CurDueWeek=CurProjectedWeek,"Yes","No")

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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