{"id":916,"date":"2021-02-08T19:02:24","date_gmt":"2021-02-08T17:02:24","guid":{"rendered":"https:\/\/www.flip-design.de\/?p=916"},"modified":"2021-02-08T19:02:24","modified_gmt":"2021-02-08T17:02:24","slug":"analyze-the-power-bi-activity-logs","status":"publish","type":"post","link":"https:\/\/www.flip-design.de\/?p=916","title":{"rendered":"Analyze the Power BI Activity Logs"},"content":{"rendered":"\n<p>To get insights into your activities of Power BI from your users you have multiple options:<br>&#8211; The Usage Metrics<br>&#8211; The Audit Logs<br>&#8211; \u2026 and the Activity Logs<br><br>For me fits the last one, because you do not need an Exchange license (you need this for the Audit Logs) and the Metrics App is too graphical and, at least you cannot export the data. To export the data, I have written this PowerShell Script:<\/p>\n\n\n\n<p><code>Login-PowerBI<br>#\u00a090\u00a0days\u00a0backwards90..1\u00a0|foreach\u00a0{\u00a0\u00a0\u00a0\u00a0$Date\u00a0=\u00a0(((Get-Date).Date).AddDays(-$_))\u00a0\u00a0\u00a0\u00a0\"$Date\"<br>\u00a0\u00a0\u00a0\u00a0$StartDate\u00a0=\u00a0(Get-Date\u00a0-Date\u00a0($Date)\u00a0-Format\u00a0yyyy-MM-ddTHH:mm:ss)\u00a0\u00a0\u00a0\u00a0$EndDate\u00a0=\u00a0(Get-Date\u00a0-Date\u00a0((($Date).AddDays(1)).AddMilliseconds(-1))\u00a0-Format\u00a0yyyy-MM-ddTHH:mm:ss)\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0$ActivityLogs\u00a0=\u00a0Get-PowerBIActivityEvent\u00a0-StartDateTime\u00a0$StartDate\u00a0-EndDateTime\u00a0$EndDate\u00a0|\u00a0ConvertFrom-Json\u00a0\u00a0\u00a0\u00a0$ActivityLogSchema\u00a0=\u00a0$ActivityLogs\u00a0|\u00a0`\u00a0\u00a0\u00a0\u00a0Select-Object\u00a0Id,RecordType,CreationTime,Operation,OrganizationId,UserType,UserKey,Workload,\u00a0`\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0UserId,ClientIP,UserAgent,Activity,ItemName,WorkspaceName,DatasetName,ReportName,\u00a0`\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0WorkspaceId,CapacityId,CapacityName,AppName,ObjectId,DatasetId,ReportId,IsSuccess,\u00a0`\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0ReportType,RequestId,ActivityId,AppReportId,DistributionMethod,ConsumptionMethod,\u00a0`\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0@{Name=\"RetrieveDate\";Expression={$RetrieveDate}}\u00a0\u00a0\u00a0\u00a0#\u00a0Write\u00a0a\u00a0file\u00a0per\u00a0day\u00a0\u00a0\u00a0\u00a0\u00a0$ActivityLogSchema\u00a0|\u00a0Export-Csv\u00a0c:\\temp\\audit\\PowerBI_AudititLogs-$((($Date).ToUniversalTime()).ToString(\"yyyyMMddThhmmssZ\")).csv<br>}<\/code><\/p>\n\n\n\n<p>This script exports the data of the last 90 days. (Power BI saves only the last 90 days). If you have already exported a single day, the scripts overwrite the existing files which are already exists. In my experience I got sometimes a timeout for some days by exporting. So, I think it is not a good idea to export only after this timeframe and it is better to export every day or week.<br>After you have exported the logs, you can import the folder into Power BI Desktop on analyze the data like this:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.flip-design.de\/wp-content\/uploads\/2021\/02\/image-3.png\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"591\" src=\"https:\/\/www.flip-design.de\/wp-content\/uploads\/2021\/02\/image-3-1024x591.png\" alt=\"\" class=\"wp-image-917\" srcset=\"https:\/\/www.flip-design.de\/wp-content\/uploads\/2021\/02\/image-3-1024x591.png 1024w, https:\/\/www.flip-design.de\/wp-content\/uploads\/2021\/02\/image-3-300x173.png 300w, https:\/\/www.flip-design.de\/wp-content\/uploads\/2021\/02\/image-3-768x443.png 768w, https:\/\/www.flip-design.de\/wp-content\/uploads\/2021\/02\/image-3-500x288.png 500w, https:\/\/www.flip-design.de\/wp-content\/uploads\/2021\/02\/image-3.png 1158w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>You can also implement an Azure Function and write the files into a Blob storage. With this solution you can automate the export and create an automatic refresh of your Power BI report at the service.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>To get insights into your activities of Power BI from your users you have multiple options:&#8211; The Usage Metrics&#8211; The Audit Logs&#8211; \u2026 and the Activity Logs For me fits the last one, because you do not need an Exchange &hellip; <a href=\"https:\/\/www.flip-design.de\/?p=916\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0},"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/www.flip-design.de\/index.php?rest_route=\/wp\/v2\/posts\/916"}],"collection":[{"href":"https:\/\/www.flip-design.de\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.flip-design.de\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.flip-design.de\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.flip-design.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=916"}],"version-history":[{"count":2,"href":"https:\/\/www.flip-design.de\/index.php?rest_route=\/wp\/v2\/posts\/916\/revisions"}],"predecessor-version":[{"id":930,"href":"https:\/\/www.flip-design.de\/index.php?rest_route=\/wp\/v2\/posts\/916\/revisions\/930"}],"wp:attachment":[{"href":"https:\/\/www.flip-design.de\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=916"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.flip-design.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=916"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.flip-design.de\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=916"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}