Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hello all,
i need to calculate days360 or YEARFRAC between two dates in power query. how do i do this?
this is what i need to replicate but in M
YEARFRAC([Start Date],[End Date],0)
i need to create a custom column
thanks,
Amrita
Solved! Go to Solution.
Hi @amrosullivan ,
You can create a custom column like this
(Number.From([EndDate]) - Number.From([StartDate]) ) /365
Please keep in mind this does not take into account leap years.
Kind regards,
Rohit
Please mark this answer as the solution if it resolves your issue.
Appreciate your kudos! 😊
Hi @amrosullivan ,
The Query Editor side of things uses a language called Power Query M, not DAX. As far as I know, YEARFRAC is only available in DAX, so that would be a measure or a calculated column after your data is loaded, rather than a custom column in the Query Editor.
Best Regards,
Stephen Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
This will have to be done through a proper function as it can't be done through one liner formulas. Too many conditions to be handled regarding leap year and start and end dates. Here is M version for YEARFRAC
https://www.thebiccountant.com/2022/03/12/excel-yearfrac-for-power-query/
Hi @amrosullivan ,
You can create a custom column like this
(Number.From([EndDate]) - Number.From([StartDate]) ) /365
Please keep in mind this does not take into account leap years.
Kind regards,
Rohit
Please mark this answer as the solution if it resolves your issue.
Appreciate your kudos! 😊
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 19 | |
| 10 | |
| 9 | |
| 7 | |
| 6 |