Forum Discussion

powerbiexpert22's avatar
powerbiexpert22
Impactful Individual
1 year ago
Solved

DAX learn

  • 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 

6 Replies

  • 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 🙂

  • powerbiexpert22's avatar
    powerbiexpert22
    Impactful Individual

    Hi Cookistador , 

     

    thanks, it is more clear theoritically now, can you give me use cases or examples of above in terms of Power BI, I am not when i should use ( in which scenario) which one ?

    • Cookistador's avatar
      Cookistador
      Super User

      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 
  • v-sgandrathi's avatar
    v-sgandrathi
    Community Support

    Hi powerbiexpert22,

    Has your issue been resolved?
    If a community member’s response addressed your query, kindly mark it as the accepted solution. This not only acknowledges their effort but also helps others with similar questions find answers more efficiently. If you found the response helpful, giving Kudos is always appreciated and encourages continued community support.

    Thankyou Cookistador for your reply on the issue.

    Continue using Microsoft Fabric Community Forum!

    • v-sgandrathi's avatar
      v-sgandrathi
      Community Support

      Hi powerbiexpert22,

       

      We strive to make sure every issue gets addressed completely. If the previous answer helped, that’s great, please mark it as Accepted and consider giving it a Kudos.

      Still facing issues? Just reply here and we’ll be right with you.

       

      Thanks for being a valued part of the community,

      • v-sgandrathi's avatar
        v-sgandrathi
        Community Support

        Hi powerbiexpert22,

         

        We wanted to follow up to see if our suggestion was helpful. Please let us know how things are progressing and if you are still encountering any issues.

        If the response resolved your problem, you may mark it as the solution and give it a thumbs up to assist others in the community as well.

         

        Thank you.