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

Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers. Get Fabric certified for FREE! Learn more

Reply
croberts21
Responsive Resident
Responsive Resident

Bug in Datediff()? How to calculate age of Invoice.

I have Power BI Desktop vMarch 2023, for Windows. 

 

I do not have a calendar table. I have an invoice table with a Proforma Date. I'm calculating the date of the Proforma based on this: Proforma age = DATEDIFF(Invoice.proformadata, TODAY(), DAY) to get the number of days. 

 

My Proforma Date is a new colum which is: Proforma Date = Invoice.[invdate].date. This date is formatted as mm/dd/yyyy (short date) in the formatting bar. 

 

One Proforma Data is listed as 10/13/23, today is 10/24/23. The age PBI gives me is 286 days. The age should be 11. All other ages for all proformas are also too high. 

 

I have tried this formula in 2 different PBIX files and the result is both incorrect, and the same, the age in days is too high.

 

Am I doing this wrong? Should this be a measure instead of a column? 

 

When I try to make a measure for this I get this error: "A single for column 'Proforma Date' in table 'Invoice' cannot be determined."

 

Thank you.

 

1 ACCEPTED SOLUTION
croberts21
Responsive Resident
Responsive Resident

Well darn. In the visual, in the Columns area, the field was set to Sum. I set it to "Don't summarize" and it works. 

View solution in original post

3 REPLIES 3
mlsx4
Memorable Member
Memorable Member

Hi @croberts21 

 

Not sure if it is the problem, but I think you need to aggregate the value. Something like:

Proforma age = DATEDIFF(TODAY(),MAX('Table'[Invoice.proformadata]),DAY)
croberts21
Responsive Resident
Responsive Resident

Well darn. In the visual, in the Columns area, the field was set to Sum. I set it to "Don't summarize" and it works. 

croberts21
Responsive Resident
Responsive Resident

Hmm. I'll try it. When I created a new measure it must be recalculating the date for 1000s of invoices, which can take me 10 minutes or more. I'll have to wait to see if it works. 

Helpful resources

Announcements
Notebook Gallery Carousel1

NEW! Community Notebooks Gallery

Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.

April2025 Carousel

Fabric Community Update - April 2025

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

Top Solution Authors