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
MennoBynco
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. 

Can you please help me.

 

MennoBynco_0-1659448827516.png

Thanks in advance.

Menno

 

1 ACCEPTED SOLUTION

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.

View solution in original post

4 REPLIES 4
Barthel
Solution Sage
Solution Sage

Use this below RETURN:

 

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

 

 

Hi Barthel, 

 

Thanks for your response. 

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

 

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.

Thanks! That's what I was looking for.

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.