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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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

Top Solution Authors
Top Kudoed Authors