I have a tabular table in SSAS containing the stock with a stock date , an SKU and other attributes.
+----------+-----+
| Date | SKU |
+----------+-----+
| 20180701 | 1 |
+----------+-----+
| 20180701 | 2 |
+----------+-----+
| 20180701 | 3 |
+----------+-----+
| 20180702 | 1 |
+----------+-----+
| 20180702 | 3 |
+----------+-----+
| 20180703 | 3 |
+----------+-----+
Per day I would like to aggregate the data by counting the distinct sku values:
CntSKU:= DISTINCTCOUNT([SKU])
However, per month I would like to sum the daily values and divide them by the days (like an average over days). The DAX seems not so difficult:
AvgSKU:= DIVIDE(
sumx(SUMMARIZE(Table;Table[Date];"CntSKU";DISTINCTCOUNT(Table[SKU]));[CntSKU])
;DISTINCTCOUNT(Table[Date])
;BLANK()
)
The performance is quite bad, though. For one month, the query time for CntSKU per day is around 7.2 seconds. The AvgSKU-measure takes around 9.5 seconds to calculate. For a bigger datasets over a couple or for several calculations inside Excel Pivot this calculation time s a more fatal lever.
The subsequent question is: Is there a better way to calculate the AvgSKU - Measure?
DISTINCTCOUNT(Table[SKU])
calculation takes over 7 seconds? How many rows is your data table? Like 100 million rows? – Alexis Olson