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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

Yes/No for Dates with 30 Days

Hello,

 

Please see the example table below. All I need to do is create a calculated column where within each cell a "Yes" will be polulated if the Date is within 30 days of today and a "No" will be populated if the date is not within 30 days of today. Please note that the data model I'm working with does not have a date table. I'm pretty sure that I need to use an IF statement along with the Today() function and have a 30 in there somewhere. 

 

Thanks in advance to anyone who can help!

 

Project IDDate
14/1/2020
23/30/2020
35/1/2020
46/1/2020
1 ACCEPTED SOLUTION
Anonymous
Not applicable

The code I posted earlier actually does work. Thanks for helping me get there.

 

Within 30 Days of Start Date = IF('Table'[Start Date].[Date]>= TODAY(),IF('Table'[Start Date].[Date] <=TODAY()+30, "Within 30 Days of Start Date","No"))

View solution in original post

12 REPLIES 12
v-eachen-msft
Community Support
Community Support

Hi @Anonymous ,

 

You could use ABS() function to return absolute value.

Column =
IF ( ABS ( DATEDIFF ( TODAY (), 'Table'[Date], DAY ) ) <= 30, "yes", "no" )

 

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.
az38
Community Champion
Community Champion

Hi @Anonymous 

try a column

Column = IF(TODAY()-30 <= [Date], "yes", "no")

do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn
Anonymous
Not applicable

Thank you. I'm thinking it would be Column =IF(TODAY()+30 <= [Date],"Yes","No")

Adding 30 days to today instead of subtracting. Thoughts?


 

az38
Community Champion
Community Champion

@Anonymous 

it depends on what do you mean "within" 🙂 within plus, within minus or within +/- 30 days 🙂


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn
Anonymous
Not applicable

I'm almost there. The below expression filters a table on projects with start dates beginning today or after today (as opposed to including projects with start dates prior to today), but it is also including projects with start dates beyond 30 days from today. I tried including AND at different points within the expression but can't get it to cooperate.

 

Within 30 Days of Start Date = IF('Table'[Start Date].[Date]>= TODAY(),IF('Table'[Start Date].[Date] <=TODAY()+30, "Within 30 Days of Start Date","No"))
 
 
az38
Community Champion
Community Champion

@Anonymous 

so, does your statement work? try without .[Date] like

Within 30 Days of Start Date = IF('Table'[Start Date] >= TODAY() && 'Table'[Start Date] <= TODAY()+30, "Within 30 Days of Start Date","No"))

do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn
Anonymous
Not applicable

My statement is working in that it filters on projects with start dates beginning today or after, but it's not truncating the list if start dates are greater than 30 days from today.

 

Your latest expression isn't working unfortunately. It pulls in start dates both prior to today and after 30 days...

az38
Community Champion
Community Champion

@Anonymous 

I did check it with my dummy data. it works as appropriated

Снимок.PNG


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn
Anonymous
Not applicable

Are the semi colons in your code significant? I'm not able to use them...

az38
Community Champion
Community Champion

@Anonymous
It’s a localization question. In the most common scenario use commas, it’s not the issue here

do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn
Anonymous
Not applicable

The code I posted earlier actually does work. Thanks for helping me get there.

 

Within 30 Days of Start Date = IF('Table'[Start Date].[Date]>= TODAY(),IF('Table'[Start Date].[Date] <=TODAY()+30, "Within 30 Days of Start Date","No"))

az38
Community Champion
Community Champion

@Anonymous
I’m glad to help you. Good luck!

do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.