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

The FabCon + SQLCon recap series starts April 14th at 8am Pacific. If you’re tracking where AI is going inside Fabric, this first session is a can't miss. Register now

Reply
dkwilson
Frequent Visitor

DATESBETWEEN ( LASTDATE ( ...

Dear BI Sectarians,

 

I have a table of clients (primary) related to a table of contracts (foreign). The contracts table has multiple rows (contracts) for each client.

 

I am trying to write a measure which will return all contract values for those clients whose most recent contract ends within the current fiscal year (this would also exclude those who have renewed).

 

The CALCULATE filter would look something like this -- 

 

DATESBETWEEN ( LAST DATE ( Contracts[Contract End Date] ) , &c.

 

-- but it returns the error, ""DatesBetween and DatesInPeriod functions are only accepting date column reference as a first argument."

 

(I've tried to build a virtual column but I can't seem to get that one right.)

 

Can someone please advise?

 

Thanks in advance,

 

 

 

Derek

2 REPLIES 2
v-piga-msft
Resident Rockstar
Resident Rockstar

Hi @dkwilson ,

Based on the document, the syntax of the DATESBETWEEN function is below.

DATESBETWEEN(<dates>,<start_date>,<end_date>)

The dates should be a reference to a date/time column.

So for your scenario, I'm afraid that your issue is caused by the LAST DATE ( Contracts[Contract End Date] ).

You'd better enter the <date> with a column like DateTime[DateKey] as the document shows.

Normally, if we want to use Time Intelligence functions, we'd better create a calendar table.

Best Regards,

Cherry

 

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you for your reply, @v-piga-msft .

 

I actually do have a separate dates/calendar table.

 

Basically, I'm trying to write a measure that will return the contract value for current clients whose annual contract ends within the current fiscal year and who have not yet renewed. The problem is, Client A has renewed its annual contract and, therefore, the end date for its latest / most recent contract falls outside the current fiscal year. Its original contract does end within the current fiscal year but I want to exlude Client A from this measure by using the contract end date from its latest / most recent contract.

 

I hope I've explained myself clearly. My first thought is to find some alternative to a "DATESBETWEEN ( LASTDATE ( ..." filter but I would be grateful for any advice.

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.