Skip to main content
Showing results for 
Search instead for 
Did you mean: 

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Frequent Visitor

Weird behavior in dax measure

Good afternoon.


Please, watch this two measures:


Version 1:


Anul.Ped.netos € =
VAR fecha = [Fecha últ. pedido]
        [Anul.Ped.reales €];
        FILTER (
            'HECHOS Pedidos anulados';
            'HECHOS Pedidos anulados'[Fechaanulacion_ID] <= fecha


Version 2:


Anul.Ped.netos € =
        [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.

Microsoft Employee
Microsoft Employee

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 🙂

To learn more about DAX visit :

Proud to be a Datanaut!

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.

Helpful resources

July 2024 Power BI Update

Power BI Monthly Update - July 2024

Check out the July 2024 Power BI update to learn about new features.


Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

Top Solution Authors