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.
Does anybody know why these measure are showing different data? I think it is because the variable doesn't recalculate in the second step.
I would say that is likely, you generally do not re-calculate a VAR. I'm actually sort of surprised it lets you do it and you don't get a syntax error. Tough to say really without sample data. Is the 2nd one giving you the correct result that you are looking for?
Yes the second one is doing the job. But there i do not use the variable.
Is the second one using a measure? Just curious.
But, yes, once you set a VAR it doesn't change in value, unless you get into nesting like in my Runge-Kutta Quick Measure but that's a very specialized case.
The second one also uses measures. See next
This calculates the amount to pay to to the workforces for the previous Fiscal year. Because these Fiscal years are not always from jan untill dec and change per yaer. Also it is not the same for every company in my dataset. So actualy it is the same as calculate([_personeel];previousyear(_Boekperiod[Date])) but because i need to look at so many different factors i need to calculate it like this one underneath. This measure does work.
Personeel PFY =
IF (
HASONEVALUE ( _Boekperiod[tdboekper_boekper] );
IF (
HASONEVALUE ( _Boekperiod[Bedrijf] );
//For Single Company
CALCULATE (
[_Personeel];
FILTER (
ALL ( _Boekperiod );
_Boekperiod[Boekjaar]
= SELECTEDVALUE ( _Boekperiod[Boekjaar] ) - 1
&& _Boekperiod[tdboekper_boekper]
= SELECTEDVALUE ( _Boekperiod[tdboekper_boekper] )
&& _Boekperiod[Bedrijf] = SELECTEDVALUE ( _Boekperiod[Bedrijf] )
)
);
//For All Companies (total)
CALCULATE (
[_Personeel];
FILTER (
ALL ( _Boekperiod );
_Boekperiod[Boekjaar]
= SELECTEDVALUE ( _Boekperiod[Boekjaar] ) - 1
&& _Boekperiod[tdboekper_boekper]
= SELECTEDVALUE ( _Boekperiod[tdboekper_boekper] )
)
)
);
IF (
HASONEVALUE ( _Boekperiod[Bedrijf] );
//For Single Company
CALCULATE (
[_Personeel];
FILTER (
ALL ( _Boekperiod );
_Boekperiod[Boekjaar]
= SELECTEDVALUE ( _Boekperiod[Boekjaar] ) - 1
&& _Boekperiod[Bedrijf] = SELECTEDVALUE ( _Boekperiod[Bedrijf] )
)
);
//For All Companies (total)
CALCULATE (
[_Personeel];
FILTER (
ALL ( _Boekperiod );
_Boekperiod[Boekjaar]
= SELECTEDVALUE ( _Boekperiod[Boekjaar] ) - 1
)
)
)
)
Yes, once you declare a variable its contents are immutable, a constant actually.
In [Bedrag PFY] you're using the variable Calculateddmeasure in the first argument of the CALCULATE. Its contents will not change, it is not affected by the filter arguments. It's like if you did CALCULATE( 3, FILTER( .....)), you'd always get a 3
In [Bedrag PFY2], on the contrary, you are using the measure [Bedrag (c)] directly instead of the variable and that gets recalculated within the filter context created by CALCULATE, as usual.
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 |
---|---|
112 | |
100 | |
80 | |
64 | |
57 |
User | Count |
---|---|
146 | |
110 | |
93 | |
84 | |
67 |