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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Marissa_Austin
Regular Visitor

How do I use a table column to calculate the Duration.Days of overdue invoices? (Syntax?)

I have been trying to get this calculation column together, but have not been able to succeed. If the syntax is Value.ReplaceType(any value, new type) what's going on with this error code? I thought Duration.Days requires numbers, not dates, so how do I convert it?

M QueryM Query

 

Error CodeError Code

 

If you have any better routes to take, I'm all ears. I just want to be able to upload an excel report, and based on the invoice date show me how many days old it is.

 

Side curiosity, is there a difference between Referencing and Duplicating a table? I feel like there must be but I can't figure it out.

1 ACCEPTED SOLUTION
ronrsnfld
Super User
Super User

I don't know where you got that idea. But:

 

= Table.AddColumn(#"Previous Step", "Duration", each Duration.Days(Date.From(DateTime.LocalNow()) - [Invoice Date]), Int64.Type)

 

Replace #"Previous Step" with the name of the Step preceding this line of code that contains the table to which you want to add the "Duration" column

View solution in original post

2 REPLIES 2
ronrsnfld
Super User
Super User

I don't know where you got that idea. But:

 

= Table.AddColumn(#"Previous Step", "Duration", each Duration.Days(Date.From(DateTime.LocalNow()) - [Invoice Date]), Int64.Type)

 

Replace #"Previous Step" with the name of the Step preceding this line of code that contains the table to which you want to add the "Duration" column

Thank you! A lot of this I'm able to work through based on intuition and the definition guide, but I was pulling my hair out with that one. Worked like a charm!

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors