Forum Discussion
Using a measure into Calculate+Filter VS using a constant equal to my measure
Hi,
I'm running some test to set my (pretty simple) measure but there is a thing that I dont understand.
When I use :
Version1 =
2 + CALCULATE(sum(FORECAST[Forecast]),filter(FORECAST,FORECAST[position]<=2))My result is correct.
The constant 2 (used 2 times) is actually the result of another measure X. And I confirm that when I check the result of this measure, it is 2.
And when I use :
Version2 =
X + CALCULATE(sum(FORECAST[Forecast]),filter(FORECAST,FORECAST[position]<=X))The result is not correct.
I'm sure that the first X is correctly interpreted as a 2, but not the 2nd one.
I don't understand this and i'm not able to find the logic used to find the same result than the machine.
Do you think the use of X inside Calculate + filter changes somehow the meaning of the calculation ?
Thank you for your help
3 Replies
- amitchandakSuper User
Anonymous , As a measure, is calculated at each row and grand total level. Your calculation will change based on that
You need to use some kind group
Version2 =
sumx(values(FORECAST[columns]), X + CALCULATE(sum(FORECAST[Forecast]),filter(FORECAST,FORECAST[position]<=X)))change columns to with group by you want in visual
- AnonymousNot applicable
Hi Anonymous ,
If your metric is placed in a view with multiple fields, the results will be affected by rows, as in the following simple example.
x = CALCULATE(sum(FORECAST[Forecast]),filter(FORECAST,FORECAST[position]=2))If you want the x measure to return the same result in all rows, add the ALL function.
x = CALCULATE(sum(FORECAST[Forecast]),filter(ALL(FORECAST),FORECAST[position]=2))Best Regards,
Stephen Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- AnonymousNot applicable
Thanks for your answer, but actually I have completely changed my datamodel, and I.m not exposed to this problem anymore.... I guess I did something bad in my first datamodel.
Thank you guys for having tried to help.