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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
sivasrao
Helper III
Helper III

Compare two date columns from different tables

Hi,

I have 2 different tables(Table1 and Table2) having the same column names.

In Table 1, we have the Date column and corresponding Week column of the particular date.

Table 2 also same Date Column and here we have to find the week of the date.

 

My requirement is: 

The logic behind the "Compare two date columns, when both dates are equal then the corresponding week(Table1) value is copied into the table 2 week column".

 

     Table 1
DateWeek 
  

 

     Table 2
DateWeek 
  

 

Thank you in advance.

1 ACCEPTED SOLUTION
v-binbinyu-msft
Community Support
Community Support

Hi @sivasrao ,

Please try below steps:

1. below is my test table

Table1:

vbinbinyumsft_0-1669687074735.png

Table2:

vbinbinyumsft_1-1669687093285.png

2. create a measure with below dax formula

Week2 =
VAR cur_date =
    SELECTEDVALUE ( Table2[Date] )
RETURN
    CALCULATE (
        MAX ( Table1[Week] ),
        FILTER ( ALL ( Table1 ), Table1[Date] = cur_date )
    )

3. add table visual with fields and measure

vbinbinyumsft_3-1669687267428.png

Please refer the attached .pbix file.

 

Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-binbinyu-msft
Community Support
Community Support

Hi @sivasrao ,

Please try below steps:

1. below is my test table

Table1:

vbinbinyumsft_0-1669687074735.png

Table2:

vbinbinyumsft_1-1669687093285.png

2. create a measure with below dax formula

Week2 =
VAR cur_date =
    SELECTEDVALUE ( Table2[Date] )
RETURN
    CALCULATE (
        MAX ( Table1[Week] ),
        FILTER ( ALL ( Table1 ), Table1[Date] = cur_date )
    )

3. add table visual with fields and measure

vbinbinyumsft_3-1669687267428.png

Please refer the attached .pbix file.

 

Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you for your quick reply.

I have created a new column with this function and executed it successfully.

 

CALCULATE (
        MAX ( Table1[Week] ),
        FILTER ( ALL ( Table1 ), Table1[Date] = cur_date )

 

Thank you.

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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