Dax Tips and Tricks: Divide vs Divide

An interesting function on DAX si DiVIDE.

Un interessante funzione che pochi conoscono e sfruttano in DAX è DIVIDE. It often happens that when you create a measure in dax , especially if you take advantage of the time intelligence you want to create delta and Delta % Measure.

Normally a person would write , to make a Delta % vs PY CY , the following formula :

Delta % CY vs PY := ([AMount CY] -[Amount PY]) / [Amount PY]

What usually happens is the abscence of py data, dax not handle in automatic a value divide by zero  and this is what happen:

dax.PNG

A simple solution can be use the if statement:

if(isblank([amount py]);0;formula).

This Formula is very inefficient for you and for the model, you have to use this:

Delta % CY vs PY:=divide([AMount CY] -[Amount PY];[Amount PY];0)

In automatic way Dax control if it’s possible to do the division, if isn’t possible then:

  • insert blank value if i don’t insert nothing in the formula
  • Insert specific value ( in our example the zero value)
Annunci

Rispondi

Inserisci i tuoi dati qui sotto o clicca su un'icona per effettuare l'accesso:

Logo WordPress.com

Stai commentando usando il tuo account WordPress.com. Chiudi sessione / Modifica )

Foto Twitter

Stai commentando usando il tuo account Twitter. Chiudi sessione / Modifica )

Foto di Facebook

Stai commentando usando il tuo account Facebook. Chiudi sessione / Modifica )

Google+ photo

Stai commentando usando il tuo account Google+. Chiudi sessione / Modifica )

Connessione a %s...