Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Calulate previous year value without use function sameperiodlastyear or other functions

this is my data model

 

https://www.dropbox.com/s/x6wtywkor1gdy3q/UpdatingSlicer.pbix?dl=0

 

assuming there will be an extra column in my data model as  "amont" value .

my goal is to calculate the previous year " amount"without using sameperiod last year( or at least i see in my datamodel this will not work, if you find the way to use it let me know),  so i can compare this year sum with previous year values.

 the value will be use with a periood slicer based on column "monthslicer"

my goal is 

1. When I choose the 2019-01, the measure shows sum(value) of 2018-01

2. When I choose the 2019-01 and 2019-02, the measure shows sum(value) of 2018-01 and 2018-02

3. When I choose the 2018-01 and 2018-03, the measure shows sum(value) of 2017-01 and 2017-03

  • mwegener's avatar
    mwegener
    6 years ago

    Hi Anonymous ,

     

    yes. Please create a seperate Date Table.

     

    If I answered your question, please mark my post as solution, this will also help others.

    Please give Kudos for support.

7 Replies

  • mwegener's avatar
    mwegener
    Icon for Most Valuable Professional rankMost Valuable Professional

    Hi Anonymous ,

     

    you want this?

     

    Amount PY =
    CALCULATE ( SUM ( 'Table'[Amount] ); DATEADD ( DimDate[Date]; -1; YEAR ) )

     

     

    If I answered your question, please mark my post as solution, this will also help others.

    Please give Kudos for support.

    • Anonymous's avatar
      Anonymous
      Not applicable

      mwegener  your solution is not working from my side,just  same as for sameperiod last year 

      DATEADD ( DimDate[Date]; -1; YEAR ) )

      this because i'm filtering the period with [monthslicer] that is a txt and not with [date] field...the result with your measure is always displaying blank ,

      im using the monthslider as period selector in order to have current month selected and  displaying everythime I open a report the currentt months year

      • mwegener's avatar
        mwegener
        Icon for Most Valuable Professional rankMost Valuable Professional

        Hi Anonymous 

         

        check this.

         

        PBIX (correct File)

         

        If I answered your question, please mark my post as solution, this will also help others.

        Please give Kudos for support.