Forum Discussion

LJAdmin's avatar
LJAdmin
Regular Visitor
6 years ago
Solved

Calculate Previuos Period

Hi all,

I'm trying to obtain a table like this:

 

SeasonValuePreviuos Season
2020150006000
201966000

 

 

 

but i can't managed to calculate the Previuos Season.

 

I've tried differentes methods, but nothing seems to work.

ex.

 

Value Pvs Season= CALCULATE(sum(Table[Value]),FILTER(All(Table), Table[Season] = Table[Season] -5))
 
I'm pretty new to Power BI and DAX functions, so someone can help me?
 
Thank you in advance,
--D
  • Anonymous's avatar
    Anonymous
    6 years ago

    Hi LJAdmin ,

     

    Created for 2 scenarios.

     

    1. Your season value differs by 5 everytime.

    2. If the above is not the case, you can create an index column .

     

     

    You can get your values by creating Calculated Columns

     

     

    Create a Calculated Column

     

    Previous Value =
    // Incase you have an Index Column
    //CALCULATE(MAX('Table'[Value]), FILTER('Table','Table'[Index Value] > EARLIER('Table'[Index Value])))


    //Incase your Season Value Differs by 5
    CALCULATE(MAX('Table'[Value]), FILTER('Table','Table'[Season] = EARLIER('Table'[Season])-5))
     
     
     
    You can also get your values using Measures
     
     
     
    Previous Value Measure =
    // Incase you have an Index Column
    //CALCULATE(MAX('Table'[Value]), FILTER(ALL('Table'), MAX('Table'[Index Value]) = 'Table'[Index Value] - 1 ))


    //Incase your Season Value Differs by 5
    CALCULATE(MAX('Table'[Value]), FILTER(ALL('Table'),MAX('Table'[Season]) = 'Table'[Season]+5))
     
     
     
    Regards,

    Harsh Nathani

    Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)

     
     
     

3 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi LJAdmin ,

     

    Created for 2 scenarios.

     

    1. Your season value differs by 5 everytime.

    2. If the above is not the case, you can create an index column .

     

     

    You can get your values by creating Calculated Columns

     

     

    Create a Calculated Column

     

    Previous Value =
    // Incase you have an Index Column
    //CALCULATE(MAX('Table'[Value]), FILTER('Table','Table'[Index Value] > EARLIER('Table'[Index Value])))


    //Incase your Season Value Differs by 5
    CALCULATE(MAX('Table'[Value]), FILTER('Table','Table'[Season] = EARLIER('Table'[Season])-5))
     
     
     
    You can also get your values using Measures
     
     
     
    Previous Value Measure =
    // Incase you have an Index Column
    //CALCULATE(MAX('Table'[Value]), FILTER(ALL('Table'), MAX('Table'[Index Value]) = 'Table'[Index Value] - 1 ))


    //Incase your Season Value Differs by 5
    CALCULATE(MAX('Table'[Value]), FILTER(ALL('Table'),MAX('Table'[Season]) = 'Table'[Season]+5))
     
     
     
    Regards,

    Harsh Nathani

    Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)

     
     
     
    • LJAdmin's avatar
      LJAdmin
      Regular Visitor

      Hi,

      thank you very much! It works with the Measure Case.