Forum Discussion

powerbiexpert22's avatar
powerbiexpert22
Impactful Individual
1 year ago
Solved

DAX learn

i tried to understand the difference between earlier and earliest functions by going through below however i am still not clear   https://www.youtube.com/watch?v=a1SK68BYmec&pp=ygUcZWFybGllciB2cyBl...
  • Cookistador's avatar
    1 year ago

    Hi powerbiexpert22 

     

    The difference between both functions is pretty confusing

     

    EARLIER: Gets the value from the previous (outer) row context. If you have two row contexts, it grabs from the one just outside the current one. If you have more, you can specify how many levels out you want.

     

    EARLIEST: Always gets the value from the very first (outermost) row context, no matter how many are nested.

     

    If you only have two row contexts, they do the same thing. The difference becomes important with three or more nested row contexts.

     

    You use EARLIER when you need the immediate Outer, you will use Earliest when you need the very first one

     

    A small analogy could help you

    Imagine you’re getting ready for a cold day and you put on several layers of clothing: A t -shirt, a sweater and a coat

    EARLIER is like saying, "Let me check the layer just beneath the one I’m touching now." If you’re holding your coat, EARLIER lets you look at your sweater. If you specify two levels, you can look down to your T-shirt.

    EARLIEST is like saying, "No matter how many layers I have, let me always check the very first one I put on"—your T-shirt, the bottom layer.

     

    I hope wih these explanations it looks clearer for you, if it is not, do not hesistate for more help 🙂

  • Cookistador's avatar
    Cookistador
    1 year ago

    In fact, Earlier and Earliest are the same function

    Earliest, it is just taking the last level for your evaluation

     

    If you use Earlier, you can pass a second parameter

    Num: (Optional) A positive number to the outer evaluation pass.
     
    The next evaluation level out is represented by 1; two levels out is represented by 2 and so on.
     
    When omitted default value is 1.
     
    You can see Earlier and earliest like Parallelperiod and Lastyear, you can achieve the same result with both, but Paralleperiod has more versality