Evaluation of variables in DAX

preview_player
Показать описание
Variables in DAX are constants, and this could be very confusing! Watch this video to understand how the evaluation of variables works in DAX.
Рекомендации по теме
Комментарии
Автор

I love these nice short videos. Very clear and direct.

MilhouseBS
Автор

spot on and thanks for the explanation. I was hitting that wall and I figured I'd never use variables inside a calculate expression or use calculate when defining the variable - now I understand why ;)

danielsiffredi
Автор

thank you! all power bi tutors must explain this in the very beginning to save their students hours of pain :)

NikitaShilyaev
Автор

Yes, for this reason, we can define variable inside an expression (like inside any DAX function not just at the beginning). However I haven't used it in such way but seen such code.

I use variables in measures to create summary tables which later returns a single value.

Bharath_PBI
Автор

Thanks for the video, I just have one question about (2:11 minute), why is the Filter Context the same for the variable and the measure?

marcosmartin
Автор

May you please send the dataset link to download and practice

MohamedGamal-pjwd
Автор

Hours and hours lost on this one simple thing, thank you

joshblackman
Автор

Hi MrAlbertoOne of your explanation you used code like this
Maxx(Date,
sumx(
var saletable=(Sales),
return sales[qunt]*sales[Netprice])
When i tried like this it returned same result
Maxx(Date,
sumx(
Calculatable(Sales),
return sales[qunt]*sales[Netprice])
Why we Sales had as Varable table?
Vareble must not chenge context?

sbn
Автор

Hi Alberto - great videos all around. I've come to love hearing you explain all of the concepts in such detail. Can you tell me if there is such thing as an intermediary measure. Something that you can define within a DAX measure calculation? That is, in Power BI, can you create a measure within a measure, just like you can do in a DAX Studio Query with the MEASURE keyword? It would really clean up my code since I'm trying to do a lot at once. Thanks for all your amazing free content :)

taylorpigeon
Автор

this is really helpful, thanks so much

LawrenceWuVlogs
Автор

Can we use VAR SalesAmountAll = CALCULATE ( SalesAmount, ALL (Product) ) ?

yyymmmddd
Автор

Isn't it
Var SalesAmountall = [SalesAmount] and vice versa..
Or
I m just thinking wrong

Pls evaluate and Explain..

dhruvthacker
Автор

Does it matter if we use DIVIDE or / ?

gc
Автор

It's funny that way but it seems to me, DAX being a functional language, that you can substitute the VAR/RETURN construction with LET/IN, which should look familiar to those who use an other language under the Power BI umbrella.

jessamhan
Автор

Thanks, I am a bit more clear about the variable!

tangtom
Автор

could it be like this too?

pct=
var salesamount= [sales amount]
var salesAmountALL= CALCULATE( [sales amount], ALL('product'))
var result= DIVIDE( salesamount, salesamountALL)

return result

JD_
Автор

Nice content.... Does your training module cover variables in details....
Somehow I struggle in writing variables :(

madiakns
Автор

In this way readability of the code is good but still we evaluate the SalesAmount twice which is the same as before. No improvement in the performance.

saranyamurugesan
Автор

Has anyone had this; I just created a simple measure ;

and then OneV:=IF(HASONEVALUE(Table1[Test]), VALUES(Table1[Test]))
and then a row number ;
OneV VAR:=VAR onev = [OneV]
RETURN
CALCULATE([CountR], FILTER(ALL(Table1[Test]), ISONORAFTER(Table1[Test], onev, DESC)))

But if I refer to the [OneV] measure directly rather than as a VAR I get a count of 8, the total number of rows.

so this does not wrok;
CALCULATE([CountR], FILTER(ALL(Table1[Test]), ISONORAFTER(Table1[Test], [ OneV] DESC)) )
I had to declare [OneV] as Variable or type the expression into ISONORAFTER?

williamarthur
Автор

... and remember, If it's not Italian it's not DAX.

peterbogdanovich