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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Nicolas_viet
Regular Visitor

Yearfrac in Query editor does not work?

Hey there,

 

I'm trying to add a custom column showing the days (financial year) between to dates with:

"=yearfrac([StartDate],[EndDate],2)".

 

When I enter my code in the wizard for custom columns there is no syntax error but after clicking OK it keeps returning an error.

 

Translated from German it says: "I did not get Yearfrac. Is it written correctly?"

 

Can anybody help?

 

Best

Nico

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

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.

View solution in original post

3 REPLIES 3
v-piga-msft
Resident Rockstar
Resident Rockstar

Hi @Nicolas_viet,

 

Have you solved your problem?

 

If you have solved, please always accept the replies making sense as solution to your question so that people who may have the same question can get the solution directly.

 

Best Regards,

Cherry

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
ChrisMendoza
Resident Rockstar
Resident Rockstar

@Nicolas_viet,

 

If a Power Query solution is needed, try as a Custom Column:

 

M YEARFRAC ( ) = Duration.TotalDays([EndDate] - [StartDate]) / 360

Basis from your example was '2' - Actual / 360

 

You might need to figure out the precision however as this was my result:

 

1.PNG






Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

Proud to be a Super User!



Anonymous
Not applicable

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.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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