Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi Guys!
I created the following Variable:
EUR =
var summa = SUM(Sheet1[amount])
return
CALCULATE(summa;Sheet1[currency]="EUR")
I want to return the sum of EUR from my list.
The Calculate function does not want to work, it does not want to filter for EUR at all. The result is the same every time (the "summa" what I defined as a variable), no matter what I am filtering for in Calculate.
If I am Calculating the sum of EUR separately with 2 measures, than it works.
No idea what is going wrong.
Do you have any advice?
THank you
S.
Solved! Go to Solution.
Hi Sturla!
Thank you for your answer.
I have 3 other measure combinations for such calculation. I just wanted to try another way + getting familiar with the concept of variables in dax. That is why I was surprised when I did not get the expected result in the return section of the code.
I still not get it why it is so. I believed that the return section was for combining, altering all the variables defined above.
Thank you
S
Yes, the variables are a bit confusing, they are kind of static once they are calculated, so the name variables is a bit counterintuitive
Hi, @Anonymous,
what you experience is by design. The variable is calculated before the context of the measure, Currency="Eur", is applied.
For such a simple measure, there is nothing to gain by using a variable, your measure should be:
EUR =
CALCULATE (
SUM ( Sheet1[amount] );
FILTER ( SHeet1; Sheet1[currency] = "EUR" )
)
Cheers,
Sturla
If this post helps, then please consider Accepting it as the solution. Kudos are nice too.
Hi Sturla!
Thank you for your answer.
I have 3 other measure combinations for such calculation. I just wanted to try another way + getting familiar with the concept of variables in dax. That is why I was surprised when I did not get the expected result in the return section of the code.
I still not get it why it is so. I believed that the return section was for combining, altering all the variables defined above.
Thank you
S
Yes, the variables are a bit confusing, they are kind of static once they are calculated, so the name variables is a bit counterintuitive
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
42 | |
21 | |
21 | |
14 | |
13 |
User | Count |
---|---|
43 | |
39 | |
33 | |
18 | |
17 |