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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! 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
Resident Rockstar
Resident Rockstar

@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
Resident Rockstar
Resident Rockstar

Thank you for the feedback @Matt_dev 

nandic
Resident Rockstar
Resident Rockstar

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
Resident Rockstar
Resident Rockstar

@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
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

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.

Top Solution Authors