cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
aldredd
Advocate I
Advocate I

DateAdd 'randomly' returns blank value

I'm trying to use DATEADD to calculated the due date of customer invoices, but am randomly getting blank results.

 

I have two tables...

 

LEDGER

Customer | Invoice | Invoice Date

 

TERMS

Customer | TermsDays

 

I have a relationship on Customer

 

The InvoiceDate field is a calculdated field using the DATE() function, and is recognized as a date, so don't think I have any date-type issues.

 

This is my (simplified version) of my calculation

 

tmpDateAdd = DATEADD(LEDGER[InvoiceDate],RELATED(Terms[TermsDays]),DAY)

However, a good 10% of my records dont' return a result. No notable pattern. If I bring 'TermsDays' field from the 'Terms' table into my dataset, it returns a value correctly, it just doesn't seem to want to add it

 

terms.png

 

I'll have a go using simply InvoiceDate + TermsDays, but is there a reason why it would selectively miss out values like this?

2 REPLIES 2
Sean
Community Champion
Community Champion

Yes DATEADD requires contiguous date selection

So you'll need a Calendar table and then reference the 'CalendarTable'[Date] Column

 

This should work as a COLUMN in your LEDGER table

tmpDateAdd  = LEDGER[InvoiceDate] + RELATED(TERMS[TermsDays])

 

Dateadd Example2.png

Thanks Sean, that's what I went with in the end (date+days), but was curious why it wasn't work.

 

Hadn't occured to me that not using a separate calendar table, in this example, would cause me an issue - but lesson learnt!

(I spend more time in SQL Server than I do PBI, and whilst using a calendar lookup table is just as important in that environment, in this particular scenario, it wouldn't have been an issue)

 

Thanks for pointing me in the right direction though, much appreciated.

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors