title: Time-based drilldowns in Power BI powered by Azure Data Warehouse
body: <p>I have designed a simple Azure Data Warehouse where I want to track stock of my products on periodic basis. Moreover I want to have an ability to see that data grouped  by month, weeks, days and hours with ability to drill down from top to bottom. I have defined 3 dimensions:</p>
  
  <pre><code>DimDate
  DimTime 
  DimProduct
  </code></pre>
  
  <p>I have also defined a Fact table to track product stocks:</p>
  
  <pre><code>FactStocks
  - DateKey (20160510, 20160511, etc)
  - TimeKey (0..23)
  - ProductKey (Product1, Product2)
  - StockValue (number, 1..9999)
  </code></pre>
  
  <p>My fact sample data is below:</p>
  
  <pre><code>20160510 20 Product1 100
  20160510 20 Product2 30
  20160510 21 Product1 110
  20160510 21 Product2 35
  20160510 22 Product1 112
  20160510 22 Product2 28
  20160510 23 Product1 120
  20160510 23 Product2 31
  20160511 00 Product1 150
  20160511 00 Product2 29
  20160511 01 Product1 95
  20160511 01 Product2 40
  </code></pre>
  
  <p>What I need is a chart of product availability over time with ability to check total (where x axis represents hours), as well as ability to filter by specific product: </p>
  
  <pre><code>Total - 130, 145, 140, 151, 179, 135
  Product1 - 100, 110, 112, 120, 150, 95;
  Product2 - 30, 35, 28, 31, 29, 40;
  
  x-&gt; 20,21,22,23,00,01
  </code></pre>
  
  <p>Moreover I need an ability to drill up and browse average availability by days and products  (where x axis represents days, weeks, month, years available via the <code>DimDate</code> table):</p>
  
  <pre><code>Total - 141.5, 157
  Product1 - 110.5, 122.5
  Product2 - 31, 34.5
  
  x-&gt; 20160510, 20160511
  </code></pre>
  
  <p>It seems that <code>Power BI</code> is unable to make that group by date thing, because it's trying to use an aggregate function to get the daily value and there is no ability to specify the average function which will take into account products (with grouping by product). The aggregating function just doesn't work here, Power BI is trying to sum all values across all products for a given day and get the average (e.g. for 20160511):</p>
  
  <pre><code>150+29+95+40 / 4 = 78.5
  </code></pre>
  
  <p>When what I need is the following:</p>
  
  <pre><code>(150+29) + (95+40) / 2 = 157
  </code></pre>
  
  <p>I just want to make it interactive with an ability to chose a product and easily drill up and down. Please advise how I should modify my Warehouse structure to support my scenario.</p>