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

Get Fabric certified for FREE! Don't miss your chance! Learn more

Reply
sunny18pc
Regular Visitor

Tenure Calculatoin

Hope you are doing well.

 

I am having trouble with a calculation:

if [Active Stage] = "Active" then Duration.Days( [today]-[Joining]) else 0)

 

I am trying to find the tenure of employee but it keeps me throwing the error below for every Active records in Active Stage.
Expression.Error: We cannot apply operator - to types Text and Date.
Details:
Operator=-
Left=18-07-2024
Right=26-07-2023

 

today column=DateTime.ToText(DateTime.LocalNow(), "dd-MM-yyyy"))

 

Any help or suggestions to over come this error would be of great help. enclosing the scrrenshot to validate the date format.

 

sunny18pc_0-1721310466735.png

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @sunny18pc 

 

You can use below code for today. It still remains date type. 

 

today column=Date.From(DateTime.LocalNow())

 

Best Regards,
Jing

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @sunny18pc 

 

You can use below code for today. It still remains date type. 

 

today column=Date.From(DateTime.LocalNow())

 

Best Regards,
Jing

dufoq3
Super User
Super User

Hi @sunny18pc, you have to change type for [today] column to date bofore you apply the formula.

 

 


Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

Helpful resources

Announcements
Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.