Var and long dax

what is var in dax code? how can learn faster to write long dax code?

Keyword to declare variables

By practicing.

2 Likes

@dipeshkumar30,

Here’s a thread with some resources that I think you’ll find very helpful in mastering the use of variables. Understanding proper use of variables is one of the absolutely fundamental skills necessary to write anything more than basic DAX code.

In addition to studying these resources, I 100% agree with @AntrikshSharma that practice and more practice is the key. Through initiatives like Problem of the Week and the Data Challenges, we offer a lot of different opportunities for that structured learning and practice. In addition, you can learn a great deal by reading DAX -related forum posts (I literally learn something new about DAX from every @AntrikshSharma post) and also attempting to solve other peoples’ DAX problems , whether you post a solution or not.

https://forum.enterprisedna.co/t/which-enterprise-dna-course-to-master-dax-variables/5837/2?u=brianj

I hope this is helpful. Good luck with your study.

– Brian

P.S. I also used to think the goal was learning to write long, complex DAX. I now realize the better goal is to write the shortest, simplest DAX that will solve your problem. The way to do that is often not to write DAX at all, but to focus first on structuring your data and performing necessary calculations and transformations in Power Query. The lesson I learned is that you need to have a balanced study plan, advancing your skills equally in both tools.

3 Likes

Hi there,

It is a general question.

However, I’d say that If VAR is used in the DEFINE section of an EVALUATE statement, it can be used in any expression of the statement and the RETURN keyword cannot be used.

It does worth to watch Sam’s video:

https://dax.guide/st/var/#:~:text=VAR%20DAX%20Statement&text=If%20VAR%20is%20used%20in,RETURN%20keyword%20cannot%20be%20used.&text=The%20expression%20is%20evaluated%20only,VAR%2FRETURN%20expression%20is%20used.
https://docs.microsoft.com/en-us/dax/var-dax

Good luck

2 Likes

Hi @dipeshkumar30 , did the response provided by the experts help you solve your query? If not, how far did you get and what kind of help you need further? If yes, kindly mark the thread as solved. Thanks!

Hi @dipeshkular30, we’ve noticed that no response has been received from you since the 5th of January. We just want to check if you still need further help with this post? In case there won’t be any activity on it in the next few days, we’ll be tagging this post as Solved. If you have a follow question or concern related to this topic, please remove the Solution tag first by clicking the three dots beside Reply and then untick the checkbox. Thanks!

1 Like

A response on this post has been tagged as “Solution”. If you have a follow question or concern related to this topic, please remove the Solution tag first by clicking the three dots beside Reply and then untick the check box. Thanks!

1 Like

thanks a lot to everyone.

@dipeshkumar30 variables are a very, very powerful tool of Power BI and I suggest you to see this if you want to use efficiently variables:

1 Like