Time-based drilldowns in Power BI powered by Azure Data Warehouse

社会主义新天地 提交于 2019-12-05 13:24:28

I don't think you need to change your structure. I would create a New Measure on your FactStocks table (using Power BI Desktop), to calculate Availability as you require it using DAX functions.

I'm guessing a bit as you havent really spelled out your requirement besides 1 example, but it would probably look something like this:

Availability = SUM([StockValue])/DISTINCTCOUNT([ProductKey])

Here's a full tutorial on Measures in PBI Desktop:

https://powerbi.microsoft.com/en-us/documentation/powerbi-desktop-tutorial-create-measures/

I think the problem here is that your measure is actually extremely complex - what you're trying to do is sum within each day, then average across multiple days. To get this, you'll need to get your hands dirty with DAX.

I'm writing this without an editor or data, so please forgive me if I get some syntax errors or mix up my parameter order:

DailyAverage:=CALCULATE(SUMMARIZE('FactStocks', [DateKey], 'DailySum', Sum([StockValue])), AVG([DailySum]))

The principle is to SUMMARIZE (basically GROUP BY in SQL) your table, grouping by DateKey, summing up the values within each group, then average the result (now averaging one row per day instead of per row in the source table).

Could you perhaps use database views to do your calculations and aggregations?

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