Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
Please help me. From survey data I have been working with, a variable is an entity that changes. Example, Household Size could be a variable the value of which changes per household. A column that contains Household Size is a variable.
In DAX, is a Variable in the same sense as the one described above for survey data?
Solved! Go to Solution.
do you mean is the value variable or that you can set a variable to a value.
for example, when i use a variable its is because i need to precalulate something so i set a value i need into memory using a variable and then i can keep referring to that variable when i need it.
so when i use the function var variablename = my calculation. that will hold it in memory.
not sure if this makes sense or if this is not what you are asking. maybe if you can demonstrate with an example if this doesn't make sense
for example i might want calculate the % of the total households where the number of people category = "<=4"
% households where 4 or less people =
VAR totalhouseholds =
COUNTROWS ( households )
VAR cathouseholds =
CALCULATE ( COUNTROWS ( households ), category = "<=4" )
VAR result =
DIVIDE ( cathouseholds, totalhouseholds )
RETURN
result
not sure if this is what you mean?
Proud to be a Super User!
Hi Vanessafvg, I wholeheartedly accept your solution. I have benefitted a lot from it. Coming from a research background, we talk a lot about Variables. With all respect, I have to google the meaning of Variable in Research, and I got this:
In research, variables are any characteristics that can take on different values, such as height, age, temperature, or test scores. Researchers often manipulate or measure independent and dependent variables in studies to test cause-and-effect relationships. (what is a variable in research - Google Search)
Based on your explanation, with reference to the Google result and, with knowledge from other sources, I think Variables in DAX are different from Variables in research. All you explained on DAX Variables is good and I have learnt alot from it thus, you deserve an "Accept Solution". My aim is to understand the logic and concepts of DAX and you've just helped me with Variables in DAX. Thanks a million.
You will have to bear with me as I am a desprate man wanting to learn and understand DAX. Been in Power BI now for eight months, some questions from me may sound bad or difficult to understand, hence I would appreciate it if you would bear with me.
no problem, thats what we are here to do!
Proud to be a Super User!
do you mean is the value variable or that you can set a variable to a value.
for example, when i use a variable its is because i need to precalulate something so i set a value i need into memory using a variable and then i can keep referring to that variable when i need it.
so when i use the function var variablename = my calculation. that will hold it in memory.
not sure if this makes sense or if this is not what you are asking. maybe if you can demonstrate with an example if this doesn't make sense
for example i might want calculate the % of the total households where the number of people category = "<=4"
% households where 4 or less people =
VAR totalhouseholds =
COUNTROWS ( households )
VAR cathouseholds =
CALCULATE ( COUNTROWS ( households ), category = "<=4" )
VAR result =
DIVIDE ( cathouseholds, totalhouseholds )
RETURN
result
not sure if this is what you mean?
Proud to be a Super User!
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
84 | |
76 | |
73 | |
42 | |
36 |
User | Count |
---|---|
109 | |
56 | |
52 | |
48 | |
43 |