cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
dkwilson Frequent Visitor
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
Community Support Team
Community Support Team

Re: DATESBETWEEN ( LASTDATE ( ...

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.
dkwilson Frequent Visitor
Frequent Visitor

Re: DATESBETWEEN ( LASTDATE ( ...

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
Exclusive LIVE Community Event #3 – Ask Arun Anything

Exclusive LIVE Community Event #3 – Ask Arun Anything

Join us in the third Triple A event!

Meet the 2020 Season 1 Power BI Super Users!

Meet the 2020 Season 1 Power BI Super Users!

It’s the start of a new Super User season! Learn all about the new Super Users and brand-new tiered recognition system.

Super User Challenge: Can You Solve These?

Super User Challenge: Can You Solve These?

We're celebrating the start of the New Super User season with our first ever Super User 'Can You Solve These?' challenge.

Power BI Desktop Update - February 2020

Power BI Desktop Update - February 2020

We are super excited for our update this month, as we are releasing two of our top community requests!

Power Platform Online Conference

Power Platform Online Conference

Join us for the first ever Power Platform Online Conference!

Top Solution Authors
Top Kudoed Authors