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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
Anonymous
Not applicable

Quick Q: Datesbetween with If statement

I want to use DatesBetween in an IF Statement:

 

=if(DatesBetween(Table[Date], Date(2021,03,09), Date(2021,03,21)),1,0)

 

This won't work because DatesBetween Returns a table of the dates between the range given.

Is there a work around/way to make this work?

I just want to mark the dates 03/09-03/21/21 in my table with a 1.. all other dates with a 0.

3 ACCEPTED SOLUTIONS
Angith_Nair
Continued Contributor
Continued Contributor

Hi @Anonymous ,

Try with this code..

 

Measure =
IF (
    AND ( Table[Date] >= DATE ( 2021, 03, 09 ), Table[Date] <= DATE ( 2021, 03, 21 ) ),
    1,
    0
)

 

View solution in original post

Anonymous
Not applicable

hi @Anonymous try with below measure

Measure = IF (MAX('Table'[Date])>= DATE ( 2021, 03, 01 )&&MAX(Table[Date]) <= DATE ( 2021, 08, 31 ),1,0)

View solution in original post

Anonymous
Not applicable

HI @Anonymous,

You can also use the aggregate function to extract the current date and use the calendar function to generate the date range and use the 'in' operator to compare with them.

Measure =
VAR currDate =
    MAX ( Table[Date] )
VAR dateRange =
    CALENDAR ( DATE ( 2021, 03, 09 ), DATE ( 2021, 03, 21 ) )
RETURN
    IF ( currDate IN dateRange, 1, 0 )

Regards,

Xiaoxin Sheng

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi @Anonymous,

Did these suggestions suitable for your scenario? If that is the case, you can consider kudo or accept it to help others who face a similar scenario.
If they not helps, please share some more detailed information to help us clarify and test your situation.

Regards,

Xiaoxin Sheng

Anonymous
Not applicable

HI @Anonymous,

You can also use the aggregate function to extract the current date and use the calendar function to generate the date range and use the 'in' operator to compare with them.

Measure =
VAR currDate =
    MAX ( Table[Date] )
VAR dateRange =
    CALENDAR ( DATE ( 2021, 03, 09 ), DATE ( 2021, 03, 21 ) )
RETURN
    IF ( currDate IN dateRange, 1, 0 )

Regards,

Xiaoxin Sheng

Anonymous
Not applicable

hi @Anonymous try with below measure

Measure = IF (MAX('Table'[Date])>= DATE ( 2021, 03, 01 )&&MAX(Table[Date]) <= DATE ( 2021, 08, 31 ),1,0)

Angith_Nair
Continued Contributor
Continued Contributor

Hi @Anonymous ,

Try with this code..

 

Measure =
IF (
    AND ( Table[Date] >= DATE ( 2021, 03, 09 ), Table[Date] <= DATE ( 2021, 03, 21 ) ),
    1,
    0
)

 

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.