Forum Discussion

processman's avatar
processman
New Member
8 years ago
Solved

Time Intelligence doubt

I have a project where instead of dividing the year into 12 months I divide it into 18 periods. Then I have a column that joins the year and the period for example 201701 (year 2017, period 01), 201801, 201818 ...).
If for each period of each year I have "Sale $" and I need to show also the sale of the same period but of the previous year, how should I do it? I already tried "sameperiodlastyear" but it does not work properly. THANK YOU!

 

Ex.

Query (201701 Sale$ 500; 201801 Sale$ 1000)

 

In table:

201801 || (Sale$) 1000  || (Sale$"Sameperiodlastyear") 500

  • Hi processman,

     

    Instead of measure, you could create calculated columns in this scenario.

     

    Year = LEFT(Query[Period],4)
    
    Sales previous year Column =
    CALCULATE (
        SUM ( Query[Sales] ),
        FILTER ( Query, Query[Period] = EARLIER ( Query[Period] ) - 100 )
    )

     

    Best regards,

    Yuliana Gu

10 Replies

  • Hi processman,

     

    Try something like this:

     

    Sales previous year =
    VAR CurrentPeriod =
        MAX ( Table[Period] )
    RETURN
        CALCULATE ( SUM ( Table[Sales] ); Table[Period] = ( CurrentPeriod - 100 ) )

    This should work based on your columns and explanation.

     

    Regards,

     

    Mfelix

    • processman's avatar
      processman
      New Member

      Thanks for the answer. Actually I need something like this:

       

      • MFelix's avatar
        MFelix
        Super User
        Hi processman

        If you add the measure that i refer and added it to you rable.visual you.will get thst exactly same.look.

        Regards,
        MFelix
  • v-yulgu-msft's avatar
    v-yulgu-msft
    Microsoft Employee

    Hi processman,

     

    Instead of measure, you could create calculated columns in this scenario.

     

    Year = LEFT(Query[Period],4)
    
    Sales previous year Column =
    CALCULATE (
        SUM ( Query[Sales] ),
        FILTER ( Query, Query[Period] = EARLIER ( Query[Period] ) - 100 )
    )

     

    Best regards,

    Yuliana Gu