Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
Good afternoon.
Please, watch this two measures:
Version 1:
Anul.Ped.netos € =
VAR fecha = [Fecha últ. pedido]
RETURN
CALCULATE (
[Anul.Ped.reales €];
FILTER (
'HECHOS Pedidos anulados';
'HECHOS Pedidos anulados'[Fechaanulacion_ID] <= fecha
)
)
Version 2:
Anul.Ped.netos € =
CALCULATE (
[Anul.Ped.reales €];
FILTER (
'HECHOS Pedidos anulados';
'HECHOS Pedidos anulados'[Fechaanulacion_ID] <= [Fecha últ. pedido]
)
)
They give different results, even though they seem to be absolutely similar. The only difference is the usage of a variable in version 1 to previously load the measure containing a single date.
May anybody please help me?
Thank you in advance.
It is to do with context and can be used to your benefit if used well.
When you declare and assign a variable, the value assigned from [Fecha últ. pedido] will be relevant for the context at play at that point.
In the 2nd example, your calls to [Fecha últ. pedido] take place with a different context (inside the CALCULATE which is converting row context to filter context).
But the short answer is, pick the one that works for you and run with that 🙂
Thanks for your reply. Actually, the one that works for me is the version that uses de variable. The other one produces incorrect results, I do not know why. The key is that I was hours trying to find why the version without variable did not work, until I tried the other one that worked.
User | Count |
---|---|
102 | |
91 | |
87 | |
79 | |
71 |
User | Count |
---|---|
113 | |
105 | |
101 | |
75 | |
64 |