Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago

Year comparison

Hi all,

      I want to compare previous year with current year. In that comparison i want to assign all the starting date of the all the months of previous year as "X" and the rest is "Y" and ending date of all the months of current year as "X" and the rest is "Y".If i add next year data the position of "X" and "Y" should change dynamically as we are now camparing the current year with next year. i used switch statement and  assigned for 2018 and 2019 but if i add 2020 i goes wrong. how do i do it dynamically?

This is the formula i have used:

 

List =
SWITCH(INT('Table'[Year]),
2018, if('Table'[day]=STARTOFMONTH('Table'[day]),"X","Y"),
2019, if('Table'[day]=ENDOFMONTH('Table'[day]),"X","Y")
)

4 Replies

  • Omega's avatar
    Omega
    Impactful Individual

    Can you share sample data with expected results? 

  • Anonymous's avatar
    Anonymous
    Not applicable

    Thank you for your Reply,

    I will explain clearly,

    The Sales ("Y") effect should be assessed every month on the same number of days and similar in nature(a Monday being compared to a Monday, and a Saturday to a Saturday). Any extra day is considered as Calendar effect ("X"). The month of June 2015 started on a Friday and ended on a Saturday, whereas the month of June 2014 started on a Thursday and ended on a Friday. Consequently, both the 1st Thursday of June 2014 and the last Saturday of June 2015 are considered as Time ("X") effect and the rest is ("Y").

    Now i should assign all the matching days (days similar in nature) as "Y" and the not similar days as "X".

    How should i assign it dynamically? 

  • v-frfei-msft's avatar
    v-frfei-msft
    Community Support

    Hi Anonymous ,

     

    Did you have a CALENDAR table? How about changing the formula as below?

     

    List =
    SWITCH(INT('Table'[Year]),
    2018, if('Table'[day]=STARTOFMONTH('CALENDAR'[date]),"X","Y"),
    2019, if('Table'[day]=ENDOFMONTH('CALENDAR'[date]),"X","Y")
    )
     
    • Anonymous's avatar
      Anonymous
      Not applicable

      I have used calender table