cancel
Showing results 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.

New Member

## Return 0 or 1 when date is between start and end date

Hi Guys,

I want my formula to return a 1 if it is between a specific start and end date. I have specified my start and end date, but whatever I try to get te formula to return a 1 for all the dates in that range I get an error.

Menno

1 ACCEPTED SOLUTION
Solution Sage

Hey,

This is because you didn't formulate 'Today' in your VAR StartDate. Is your StartDate February 1, 2022 and your EndDate November 30, 2022? For that you can use this code:

``````Trailling 63 =
VAR StartDate =
EOMONTH ( TODAY (), -7 ) + 1
VAR EndDate =
EOMONTH ( StartDate, 9 )
RETURN
CONVERT ( [Date] >= StartDate && [Date] <= EndDate, INTEGER )``````

Let me know if your start and end dates are different.

4 REPLIES 4
Solution Sage

Use this below RETURN:

``````RETURN
IF ( [Date]>= StartDate && [Date] <= EndDate, 1, 0 )``````

New Member

Hi Barthel,

With this formula it returns 1 for every date. It does not take 'today' as a starting point for my calculation.

Solution Sage

Hey,

This is because you didn't formulate 'Today' in your VAR StartDate. Is your StartDate February 1, 2022 and your EndDate November 30, 2022? For that you can use this code:

``````Trailling 63 =
VAR StartDate =
EOMONTH ( TODAY (), -7 ) + 1
VAR EndDate =
EOMONTH ( StartDate, 9 )
RETURN
CONVERT ( [Date] >= StartDate && [Date] <= EndDate, INTEGER )``````

Let me know if your start and end dates are different.

New Member

Thanks! That's what I was looking for.

Announcements

#### 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

#### Power BI Monthly Update - April 2024

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

#### Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors