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

Join the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now

Reply
eduardo
Advocate II
Advocate II

custom column error

Hi

 

I created a column with date difference, like this:

 

coluna1.png

 

 

But there is an error. The difference is 30 days, not 29. I tried this

coluna2.png

 

 

Thanks for some help

eduardo

 

1 ACCEPTED SOLUTION
v-qiuyu-msft
Community Support
Community Support

Hi @eduardo,

 

In Query Editor, when we create a calculated column by using 'Add Custom Column', we need to write formula use Power Query Formula Language. In your scenario, to calculate the difference between start date and end date with day interval, you can use Duration.Days() and Duration.From() functions like below, you can also plus "1" at the end of the formula. For more information about function, see: Duration functions.

 

=Duration.Days(Duration.From([End date]-[Start Date]))

 

q2.PNG

 

In your scenario, if you minus directly, it will return values which are not numbers, so you cann't plus '1'. But you can change this column data type to number then create another column to plus '1'.

 

q3.PNGq4.PNGq5.PNGq6.PNG

 

Best Regards,
Qiuyun Yu

 

Community Support Team _ Qiuyun Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-qiuyu-msft
Community Support
Community Support

Hi @eduardo,

 

In Query Editor, when we create a calculated column by using 'Add Custom Column', we need to write formula use Power Query Formula Language. In your scenario, to calculate the difference between start date and end date with day interval, you can use Duration.Days() and Duration.From() functions like below, you can also plus "1" at the end of the formula. For more information about function, see: Duration functions.

 

=Duration.Days(Duration.From([End date]-[Start Date]))

 

q2.PNG

 

In your scenario, if you minus directly, it will return values which are not numbers, so you cann't plus '1'. But you can change this column data type to number then create another column to plus '1'.

 

q3.PNGq4.PNGq5.PNGq6.PNG

 

Best Regards,
Qiuyun Yu

 

Community Support Team _ Qiuyun Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thanks @v-qiuyu-msft

 

I will test this solution later. 

 

ty

eduardo

 

 

@v-qiuyu-msft

I found the Duration.TotalDays function and work.

 

thank you again

 

datasComunidade.png

 

 

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.