Forum Discussion

Matt_dev's avatar
Matt_dev
Frequent Visitor
10 months ago
Solved

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

  • 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:

    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

5 Replies

  • nandic's avatar
    nandic
    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

    • Matt_dev's avatar
      Matt_dev
      Frequent Visitor

      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's avatar
    nandic
    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:

    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