Load Clockify data to Power BI

梦想与她 提交于 2020-07-23 11:03:43

问题


I'm having a Power BI report which is based on data from Clockify. So far I had to download the detailed report from clockify in order to be able to see up to date data in Power BI. I would like to get rid of this manual step and directly connect to the data stored in Clockify using the API.

I'm currently loading with following M code:

let
    Query1 = let
Source = Json.Document(Web.Contents("https://api.clockify.me/api/workspaces/",
[Headers=[#"x-api-key"="xxxxxxxxxxx"]])),
messages = Source[messages]
in
Source

This leads to a Record in Power Query which I can then turn into a table

But when I expand the table, I only get information about my Clockify Workspace but not the recorded hours. I would like to have all information in the detailed report available directly in Power BI. Hope somebody can help. Cheers!


回答1:


I replicated your query and I don't think that the endpoint you're hitting has the information you want. You'll have to search for it in the API documentation.

Anyways, here is the M code for expanding everything in that endpoint, see if it has something useful:

let
    Query1 = 
    let
        Source = Json.Document(Web.Contents("https://api.clockify.me/api/workspaces/",
            [Headers=[#"x-api-key"="YOUR-API-KEY"]])),
        #"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
        #"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"id", "name", "hourlyRate", "memberships", "workspaceSettings"}, {"id", "name", "hourlyRate", "memberships", "workspaceSettings"}),
        #"Expanded workspaceSettings" = Table.ExpandRecordColumn(#"Expanded Column1", "workspaceSettings", {"timeRoundingInReports", "onlyAdminsSeeBillableRates", "onlyAdminsCreateProject", "onlyAdminsSeeDashboard", "defaultBillableProjects", "isProjectPublicByDefault", "lockTimeEntries", "round", "projectFavorites", "canSeeTimeSheet", "projectPickerSpecialFilter", "forceProjects", "forceTasks", "forceTags", "forceDescription", "onlyAdminsSeeAllTimeEntries", "onlyAdminsSeePublicProjectsEntries", "trackTimeDownToSecond", "projectGroupingLabel", "adminOnlyPages", "automaticLock", "onlyAdminsCreateTag"}, {"timeRoundingInReports", "onlyAdminsSeeBillableRates", "onlyAdminsCreateProject", "onlyAdminsSeeDashboard", "defaultBillableProjects", "isProjectPublicByDefault", "lockTimeEntries", "round", "projectFavorites", "canSeeTimeSheet", "projectPickerSpecialFilter", "forceProjects", "forceTasks", "forceTags", "forceDescription", "onlyAdminsSeeAllTimeEntries", "onlyAdminsSeePublicProjectsEntries", "trackTimeDownToSecond", "projectGroupingLabel", "adminOnlyPages", "automaticLock", "onlyAdminsCreateTag"}),
        #"Expanded memberships" = Table.ExpandListColumn(#"Expanded workspaceSettings", "memberships"),
        #"Expanded memberships1" = Table.ExpandRecordColumn(#"Expanded memberships", "memberships", {"userId", "hourlyRate", "targetId", "membershipType", "membershipStatus"}, {"userId", "hourlyRate.1", "targetId", "membershipType", "membershipStatus"}),
        #"Expanded hourlyRate" = Table.ExpandRecordColumn(#"Expanded memberships1", "hourlyRate", {"amount", "currency"}, {"amount", "currency"}),
        #"Expanded round" = Table.ExpandRecordColumn(#"Expanded hourlyRate", "round", {"round", "minutes"}, {"round.1", "minutes"}),
        #"Expanded adminOnlyPages" = Table.ExpandListColumn(#"Expanded round", "adminOnlyPages")
    in
        #"Expanded adminOnlyPages"
in 
    Query1

If you are not using Postman and Fiddler, I recommend it for testing the endpoints and check the responses.



来源:https://stackoverflow.com/questions/59403580/load-clockify-data-to-power-bi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!