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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Matt_dev
Frequent Visitor

Power Query Implementation

Hi,

 

I have come across a process to count the hours between 2 dates, only counting working hours (https://addendanalytics.com/blog/calculate-working-hours-in-power-bi).

 

When I try to implement it I copy the full query, from "//Enter the columns for Start & End dates" to  "return..." and I replace "‘New Method'[New Start Date]" with my StartDate field and "‘New Method'[New End Date]" With my EndDate field (both StartDate and EndDate are datetime fields with 24 hr formatting) 

Unfortunately I am getting "Token EOF Expected" and when I click on show error it highlights "start_date" right at the start of the query.

I am not sure what I need to do to implement this query but I really need the resulting data.

I would be very grateful for any help.

Thank you in advance.

 

Matt

1 ACCEPTED SOLUTION
nandic
Super User
Super User

@Matt_dev 

There are two things to check.
Your question is in Power Query topics, and calculation in the blog is in DAX.
DAX is not used in Power Query (M script), but in data modelling part.

Regarding M scripts:
You must follow M query structure:

nandic_0-1760690734640.png

M query needs to start with Let .. and end with In ...

However, the script from the blog is DAX query, not M script, so it should be in data modelling, not in Power Query.

Cheers,
Nemanja

View solution in original post

5 REPLIES 5
nandic
Super User
Super User

Thank you for the feedback @Matt_dev 

nandic
Super User
Super User

Hi @Matt_dev ,
It is ok, no worries. This was first step, to make sure we are using correct environment to paste the logic from the blog.
When you try to make dax calculation (column) with that logic and when you modify it to your table/column names, does it work or you still get error?

For sure, error "Token EOF Expected" should not appear anymore.

Cheers,
Nemanja

Nemanja,

 

I believe I have the issue sorted now. I was trying to use the DAX in the Power Query window when you click on Add Column -> Custom Column in the query editor, rather than creating a new calculated column by right clicking in the main, visualisations view.

It seems to be working now but thank you very much for getting back to me after my initial mistake.

 

Your help is very much appreciated

 

Thank you 

Matt 

nandic
Super User
Super User

@Matt_dev 

There are two things to check.
Your question is in Power Query topics, and calculation in the blog is in DAX.
DAX is not used in Power Query (M script), but in data modelling part.

Regarding M scripts:
You must follow M query structure:

nandic_0-1760690734640.png

M query needs to start with Let .. and end with In ...

However, the script from the blog is DAX query, not M script, so it should be in data modelling, not in Power Query.

Cheers,
Nemanja

Sorry Nemanja, I will try to move it now 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.

Top Solution Authors