{"id":4595,"date":"2025-12-04T11:16:00","date_gmt":"2025-12-04T10:16:00","guid":{"rendered":"https:\/\/www.lieben.nu\/liebensraum\/?p=4595"},"modified":"2025-12-04T11:16:00","modified_gmt":"2025-12-04T10:16:00","slug":"average-device-daily-usage-report-in-powerbi","status":"publish","type":"post","link":"https:\/\/lieben.nu\/liebensraum\/2025\/12\/average-device-daily-usage-report-in-powerbi\/","title":{"rendered":"Average device daily usage report in PowerBI"},"content":{"rendered":"\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.lieben.nu\/liebensraum\/wp-content\/uploads\/2025\/12\/defender-average-daily-use-per-device-report.png\"><img loading=\"lazy\" decoding=\"async\" width=\"417\" height=\"545\" src=\"https:\/\/www.lieben.nu\/liebensraum\/wp-content\/uploads\/2025\/12\/defender-average-daily-use-per-device-report.png\" alt=\"\" class=\"wp-image-4596\" srcset=\"https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2025\/12\/defender-average-daily-use-per-device-report.png 417w, https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2025\/12\/defender-average-daily-use-per-device-report-230x300.png 230w\" sizes=\"auto, (max-width: 417px) 100vw, 417px\" \/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">A customer wanted to know how many hours on average their devices were being used, without modifying their configuration.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This to help target replacements, upgrades, #desks per location, #shared devices per location etc.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">At first I figured it&#8217;d be a simple task, just getting the right event ID&#8217;s from the local eventlog, but no, that required additional auditing to be enabled and how would the data flow to PowerBI?<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The next attempted data source was much better; Defender Advanced Hunting. Especially the DeviceLogonEvents table, which contains cached and interactive logons to all monitored devices. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Using logon events, we can get an idea of a device&#8217;s relative use in the fleet. It won&#8217;t be exact as measuring the time between pure lock\/unlock\/signin\/signout events.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This was fine for the customer&#8217;s purpose and checking their data the number of daily logon events (7-9) was actually much higher than the expected 2-3 per device per day (at least on Windows 11, our target OS).<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Getting that data into PowerBI turned out to be even easier \ud83d\ude42<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Option 1: use <a href=\"https:\/\/github.com\/jflieben\/assortedFunctionsV2\/blob\/main\/PowerBI\/average%20device%20usage.pbit\">my PowerBI template<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Option 2: build your own report using below steps:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Open up PowerBI and click Blank Query<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><a href=\"https:\/\/www.lieben.nu\/liebensraum\/wp-content\/uploads\/2025\/12\/image.png\"><img loading=\"lazy\" decoding=\"async\" width=\"346\" height=\"554\" src=\"https:\/\/www.lieben.nu\/liebensraum\/wp-content\/uploads\/2025\/12\/image.png\" alt=\"\" class=\"wp-image-4597\" style=\"width:175px;height:auto\" srcset=\"https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2025\/12\/image.png 346w, https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2025\/12\/image-187x300.png 187w\" sizes=\"auto, (max-width: 346px) 100vw, 346px\" \/><\/a><\/figure>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li>Open the Advanced Editor<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.lieben.nu\/liebensraum\/wp-content\/uploads\/2025\/12\/image-1.png\"><img loading=\"lazy\" decoding=\"async\" width=\"728\" height=\"227\" src=\"https:\/\/www.lieben.nu\/liebensraum\/wp-content\/uploads\/2025\/12\/image-1.png\" alt=\"\" class=\"wp-image-4598\" srcset=\"https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2025\/12\/image-1.png 728w, https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2025\/12\/image-1-300x94.png 300w\" sizes=\"auto, (max-width: 728px) 100vw, 728px\" \/><\/a><\/figure>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li>Paste the KQL query and click done<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.lieben.nu\/liebensraum\/wp-content\/uploads\/2025\/12\/image-2.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1012\" height=\"757\" src=\"https:\/\/www.lieben.nu\/liebensraum\/wp-content\/uploads\/2025\/12\/image-2.png\" alt=\"\" class=\"wp-image-4599\" srcset=\"https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2025\/12\/image-2.png 1012w, https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2025\/12\/image-2-300x224.png 300w, https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2025\/12\/image-2-768x574.png 768w\" sizes=\"auto, (max-width: 1012px) 100vw, 1012px\" \/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>KQL: <\/strong><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; highlight: [3]; title: ; notranslate\" title=\"\">\n let\n        AdvancedHuntingQuery = &quot;DeviceLogonEvents\n| where Timestamp between (ago(28d) .. now())\n| where ActionType == &quot;&quot;LogonSuccess&quot;&quot;\n| where LogonType == &quot;&quot;Interactive&quot;&quot;\n| extend LogonDate = startofday(Timestamp)\n| where LogonDate &amp;lt; startofday(now())  \n| summarize \n    FirstLogon = min(Timestamp), \n    LastLogon = max(Timestamp)\n    by DeviceName, LogonDate\n| extend UsageDuration = LastLogon - FirstLogon\n| project DeviceName, LogonDate, FirstLogon, LastLogon, UsageDuration\n| order by DeviceName asc, LogonDate desc&quot;,\n\n        HuntingUrl = &quot;https:\/\/api.security.microsoft.com\/api\/advancedqueries&quot;,\n\n        Response = Json.Document(Web.Contents(HuntingUrl, &#x5B;Query=&#x5B;key=AdvancedHuntingQuery]])),\n\n        TypeMap = #table(\n            { &quot;Type&quot;, &quot;PowerBiType&quot; },\n            {\n                { &quot;Double&quot;,   Double.Type },\n                { &quot;Int64&quot;,    Int64.Type },\n                { &quot;Int32&quot;,    Int32.Type },\n                { &quot;Int16&quot;,    Int16.Type },\n                { &quot;UInt64&quot;,   Number.Type },\n                { &quot;UInt32&quot;,   Number.Type },\n                { &quot;UInt16&quot;,   Number.Type },\n                { &quot;Byte&quot;,     Byte.Type },\n                { &quot;Single&quot;,   Single.Type },\n                { &quot;Decimal&quot;,  Decimal.Type },\n                { &quot;TimeSpan&quot;, Duration.Type },\n                { &quot;DateTime&quot;, DateTimeZone.Type },\n                { &quot;String&quot;,   Text.Type },\n                { &quot;Boolean&quot;,  Logical.Type },\n                { &quot;SByte&quot;,    Logical.Type },\n                { &quot;Guid&quot;,     Text.Type }\n            }),\n\n        Schema = Table.FromRecords(Response&#x5B;Schema]),\n        TypedSchema = Table.Join(Table.SelectColumns(Schema, {&quot;Name&quot;, &quot;Type&quot;}), {&quot;Type&quot;}, TypeMap , {&quot;Type&quot;}),\n        Results = Response&#x5B;Results],\n        Rows = Table.FromRecords(Results, Schema&#x5B;Name]),\n        Table = Table.TransformColumnTypes(Rows, Table.ToList(TypedSchema, (c) =&gt; {c{0}, c{2}}))\n\n    in Table\n<\/pre><\/div>\n\n\n<ol start=\"4\" class=\"wp-block-list\">\n<li>Edit your credentials and sign in<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.lieben.nu\/liebensraum\/wp-content\/uploads\/2025\/12\/image-3.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"324\" src=\"https:\/\/www.lieben.nu\/liebensraum\/wp-content\/uploads\/2025\/12\/image-3-1024x324.png\" alt=\"\" class=\"wp-image-4600\" srcset=\"https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2025\/12\/image-3-1024x324.png 1024w, https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2025\/12\/image-3-300x95.png 300w, https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2025\/12\/image-3-768x243.png 768w, https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2025\/12\/image-3.png 1202w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.lieben.nu\/liebensraum\/wp-content\/uploads\/2025\/12\/image-4.png\"><img loading=\"lazy\" decoding=\"async\" width=\"701\" height=\"281\" src=\"https:\/\/www.lieben.nu\/liebensraum\/wp-content\/uploads\/2025\/12\/image-4.png\" alt=\"\" class=\"wp-image-4601\" srcset=\"https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2025\/12\/image-4.png 701w, https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2025\/12\/image-4-300x120.png 300w\" sizes=\"auto, (max-width: 701px) 100vw, 701px\" \/><\/a><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.lieben.nu\/liebensraum\/wp-content\/uploads\/2025\/12\/image-5.png\"><img loading=\"lazy\" decoding=\"async\" width=\"699\" height=\"279\" src=\"https:\/\/www.lieben.nu\/liebensraum\/wp-content\/uploads\/2025\/12\/image-5.png\" alt=\"\" class=\"wp-image-4602\" srcset=\"https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2025\/12\/image-5.png 699w, https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2025\/12\/image-5-300x120.png 300w\" sizes=\"auto, (max-width: 699px) 100vw, 699px\" \/><\/a><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.lieben.nu\/liebensraum\/wp-content\/uploads\/2025\/12\/image-6.png\"><img loading=\"lazy\" decoding=\"async\" width=\"224\" height=\"161\" src=\"https:\/\/www.lieben.nu\/liebensraum\/wp-content\/uploads\/2025\/12\/image-6.png\" alt=\"\" class=\"wp-image-4603\"\/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Now you&#8217;ve got the data connected, and just need to create a table with the fields you want.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>A customer wanted to know how many hours on average their devices were being used, without modifying their configuration. This to help target replacements, upgrades, #desks per location, #shared devices per location etc. At first I figured it&#8217;d be a simple task, just getting the right event ID&#8217;s from the local eventlog, but no, that &hellip; <a href=\"https:\/\/lieben.nu\/liebensraum\/2025\/12\/average-device-daily-usage-report-in-powerbi\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Average device daily usage report in PowerBI<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,38],"tags":[],"class_list":["post-4595","post","type-post","status-publish","format-standard","hentry","category-defender","category-powerbi"],"_links":{"self":[{"href":"https:\/\/lieben.nu\/liebensraum\/wp-json\/wp\/v2\/posts\/4595","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lieben.nu\/liebensraum\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lieben.nu\/liebensraum\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lieben.nu\/liebensraum\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lieben.nu\/liebensraum\/wp-json\/wp\/v2\/comments?post=4595"}],"version-history":[{"count":0,"href":"https:\/\/lieben.nu\/liebensraum\/wp-json\/wp\/v2\/posts\/4595\/revisions"}],"wp:attachment":[{"href":"https:\/\/lieben.nu\/liebensraum\/wp-json\/wp\/v2\/media?parent=4595"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lieben.nu\/liebensraum\/wp-json\/wp\/v2\/categories?post=4595"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lieben.nu\/liebensraum\/wp-json\/wp\/v2\/tags?post=4595"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}