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

Comparing two columns- if single date value is in two weeks in all another column values

Hello everyone,

 

I'm new to DAX syntax. Couldn't figure this out. Looks easy but challenging.

Here is the situation: Comparing two date column. If a single [created_date] column value is in the last 2 weeks of any of [appointment_date] then outcome is "yes".

Like you can see table below, first row of created_date value will look all [appointment_date] values and if any of the date is the next 2 weeks then outcome will be "yes". -if we can give yes or no instead of boolean true or false it will be easy for me for later dax measures.-

So comparing in all column value is hard for me. Any advice would be appreciated greatly.

 

created_dateappointment_dateis_in
10/20/20216/17/2021Yes
10/15/202110/16/2021Yes
9/20/20219/29/2021Yes
5/20/202110/1/2021No
8/25/202110/4/2021No
6/10/202110/29/2021Yes

 

Thank you so much.

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

Hi  @Anonymous ,

 

First create a column as below:

last date = 'Table'[appointment_date]-14

Then create a dim table:

dim = ADDCOLUMNS(SELECTCOLUMNS('Table',"start date",'Table'[last date],"end date",'Table'[appointment_date]),"key",1)

Finally create a column as below:

dim = ADDCOLUMNS(SELECTCOLUMNS('Table',"start date",'Table'[last date],"end date",'Table'[appointment_date]),"key",1)

And you will see:

vkellymsft_0-1635149348382.png

For the related .pbix file,pls see attached.

 

Best Regards,
Kelly

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

 

View solution in original post

2 REPLIES 2
v-kelly-msft
Community Support
Community Support

Hi  @Anonymous ,

 

First create a column as below:

last date = 'Table'[appointment_date]-14

Then create a dim table:

dim = ADDCOLUMNS(SELECTCOLUMNS('Table',"start date",'Table'[last date],"end date",'Table'[appointment_date]),"key",1)

Finally create a column as below:

dim = ADDCOLUMNS(SELECTCOLUMNS('Table',"start date",'Table'[last date],"end date",'Table'[appointment_date]),"key",1)

And you will see:

vkellymsft_0-1635149348382.png

For the related .pbix file,pls see attached.

 

Best Regards,
Kelly

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

 

Greg_Deckler
Community Champion
Community Champion

@Anonymous Try:

 

Column =
  VAR __Date = [created_date]
  VAR __Appointments =
    ADDCOLUMNS(
      ALL('Table'[appointment_date]),
      "__diff",([appointment_date] - [created_date]) * 1.
    )
RETURN
  IF(MINX(__Appointments,[__diff])<15 && MINX(__Appointments,[__diff])>-15,"Yes","No")
    

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

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.