To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.
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_date | appointment_date | is_in |
10/20/2021 | 6/17/2021 | Yes |
10/15/2021 | 10/16/2021 | Yes |
9/20/2021 | 9/29/2021 | Yes |
5/20/2021 | 10/1/2021 | No |
8/25/2021 | 10/4/2021 | No |
6/10/2021 | 10/29/2021 | Yes |
Thank you so much.
Solved! Go to Solution.
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:
For the related .pbix file,pls see attached.
Best Regards,
Kelly
Did I answer your question? Mark my reply as a solution!
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:
For the related .pbix file,pls see attached.
Best Regards,
Kelly
Did I answer your question? Mark my reply as a solution!
@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")