Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!
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.
The Power BI Data Visualization World Championships is back! It's time to submit your entry.
| User | Count |
|---|---|
| 50 | |
| 43 | |
| 36 | |
| 33 | |
| 30 |
| User | Count |
|---|---|
| 138 | |
| 125 | |
| 60 | |
| 59 | |
| 56 |