Quantcast
Channel: SQL Server Analysis Services forum
Viewing all articles
Browse latest Browse all 14337

Optimizing a generic DAX formula - SSAS 2012 Tabular

$
0
0

Hi,

I've a SSAS 2012 Tabular model with a generic DAX formula with the corresponding value depends on Measures (Qty, Amount) and Categories (Actual, Budget, Actual vs Budget). In other terms, for each combinations of Measures and Categories I need to calculate my DAX formula. This to satisfy the user requirements.

So, I've a Facts table, the Measures table, the Categories table, the Markets table and other dimension tables, all related between them (no inactive relationships).

My generic formula is written without using an IF statement but summing more pieces. So I calculate it respect to Actual category + formula respect to Budget category + formula for Actual vs Budget. This because I need to build an Excel pivot table where the generic formula is calculated not for a specific value for Measures filter and for Categories filter, but also for whatever values of these dimensions.

Simplifying, a piece of my generic dax formula is:

CALCULATE(
DIVIDE(
(
calculate(sum([GenericValue]), Categories[Category]="Actual") - calculate(sum([GenericValue]), Categories[Category]="Budget")
),
calculate(sum([GenericValue]), Categories[Category]="Actual"),
0)
,
FILTER(FACTS, RELATED(Categories[Category])="Actual Vs Budget")
)

Looking at this piece of formula, I've used the FILTER function to show the generic measure value in the pivot table for category equals to "Actual vs Budget" and nothing for other rows of the pivot table.

Now, with almost 10 millions of rows for FACTS table when I change the selection for a filter/slicer in the Excel pivot table I can register also a time near to 10 seconds. Too time for me, and for the user requirements. I've tried on a development vm with 8 GB as RAM. I've used Excel 2010 directly on the vm and Excel 2013 from a client workstation.

Moreover, I've dimension tables with no more of 500 distinct values.

I've used Task Manager and Performance Monitor to verify the memory and CPU resources when a filter/slicer selection occurs and I've noticed a memory usage almost constant but CPU peaks of 30-35%. So I've thought to an intensive use of the formula engine.

My idea is to avoid to use the FILTER function maintaning the pivot table behaviour and to use IF statement without summing the pieces of the formula. But for the IF statement I cannot write a function as VALUES(Categories[Category]) because I need to select a specific category as a pivot table filter to trigger the calculation without any errors. My generic formula must be always calculated also for all filter values for Measures and Categories.

Any suggests to improve the performances of my generic formula?

Many thanks 


Viewing all articles
Browse latest Browse all 14337


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>