Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

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 4
v-frfei-msft
Community Support
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")
)
 
Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.
Anonymous
Not applicable

I have used calender table 

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").y1.png

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? 

Omega
Impactful Individual
Impactful Individual

Can you share sample data with expected results? 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.