Skip to main content
cancel
Showing results for 
Search instead 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.

Reply
i820017
Resolver II
Resolver II

DATESBETWEEN Issue

I am creating a calculated column from 2 other columns in my app, and I am getting this error.

 

i820017_0-1651523347674.png

 

Why I am getting this error? and how can I fix it?

 

 

1 ACCEPTED SOLUTION
HotChilli
Super User
Super User

Thanks, very succinct answers.  I'm not used to it.

Right, so DATESBETWEEN returns a column of dates and that's why it is used with a Dates table (not  a Fact table).  It's also usually used with a measure not a column.

So, if we try and solve all issues here with DATESBETWEEN, I don't think we're going to achieve anything.

I think you are trying to test if the PTO_Calendar[End_date_repeat] is in the period of January 2022.  Is that right?

If so, you can remove the DATESBETWEEN and just use YEAR and MONTH functions to test.

Let me know.

View solution in original post

4 REPLIES 4
HotChilli
Super User
Super User

Thanks, very succinct answers.  I'm not used to it.

Right, so DATESBETWEEN returns a column of dates and that's why it is used with a Dates table (not  a Fact table).  It's also usually used with a measure not a column.

So, if we try and solve all issues here with DATESBETWEEN, I don't think we're going to achieve anything.

I think you are trying to test if the PTO_Calendar[End_date_repeat] is in the period of January 2022.  Is that right?

If so, you can remove the DATESBETWEEN and just use YEAR and MONTH functions to test.

Let me know.

Thanks!!...Using Month and Year worked.

i820017
Resolver II
Resolver II

Here are the answers to your questions:

1. PTO_Calendar[End_date_repeat] is a date column that contains duplicates.

2. PTO_Calendar is a Fact Table.

3. I just switched 2nd and 3rd parameters to date expressions as seen below.

 

i820017_0-1651526351250.png

 

 

 

HotChilli
Super User
Super User

Is PTO_Calendar[End_date_repeat] a date column which contains duplicates?

--

Also, DAX time intelligence functions work best with a Dates table which contains a column of unique dates.  Is that what PTO_Calendar is, or is that a Fact table?

And, finally, the 2nd and 3rd parameters passed to DATESBETWEEN should be date expressions.  These ones look like strings

Helpful resources

Announcements
Microsoft Fabric Learn Together

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

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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