Watch videos with subtitles in your language, upload your videos, create your own subtitles! Click here to learn more on "how to Dotsub"

DAX4_001

0 (0 Likes / 0 Dislikes)
  • Embed Video

  • Embed normal player Copy to Clipboard
  • Embed a smaller player Copy to Clipboard
  • Advanced Embedding Options
  • Embed Video With Transcription

  • Embed with transcription beside video Copy to Clipboard
  • Embed with transcription below video Copy to Clipboard
  • Embed transcript

  • Embed transcript in:
    Copy to Clipboard
  • Invite a user to Dotsub
You can use variables in your DAX expressions to avoid repeating parts of your DAX expressions. Let's hear Alberto talk a bit more about how you can use them and why they're really useful. [Alberto] The last thing which is extremely useful and new in Power BI— but this is also supported in Excel 2016— is the usage of variables. Variables are extremely powerful and they are extremely useful to use even if I can— I understand that if you are new to DAX right now, you look at them and say, "Well, why are they so useful?" It will come later in the day. But basically you can define a variable— wherever you have a DAX expression you define the variable saying your TotalQuantity is the SUM of Sales[Quantity]. And then you refer to the variable inside your code. So the pattern is always VAR and then RETURN, where VAR defines the variable and RETURN returns the result of the expression. Inside the return pattern, you can use the variable multiple times. It is important first of all for readability of the code— because this might be a very complex expression that you don't want to repeat multiple times in your code. You write it only once, and once it's there you can use it as many times as you want. And the second very important point is that variables guarantee you that the evaluation happens only once. So if you use SUM of Sales[Quantity], SUM is a very fast operation and you typically don't worry about performances. But if that was a much more complex expression, then repeating its description multiple times might lead to the evaluation of the expression multiple times. And this, of course, is going to kill the performance of your measure. Using variables guarantees that evaluation happens only once. It happens here and here it's just used as a value which is stored in the cache of the model.

Video Details

Duration: 2 minutes and 14 seconds
Country: United States
Language: English
License: All rights reserved
Genre: None
Views: 42
Posted by: csintl on Jun 7, 2016

----- (Please provide translations for these languages: Chinese (Simplified) (chi_hans), Chinese (Traditional) (chi_hant), English (eng), French (France) (fre_fr), German (ger), Italian (ita), Japanese (jpn), Korean (kor), Portuguese (Brazil) (por_br), Russian (rus), Spanish (spa).)

Caption and Translate

    Sign In/Register for Dotsub to translate this video.