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

compare automaticaly between N and N-1

Hello ,

Is it possible in power BI to compare automaticaly between N and N-1 year;

for example I want to obtain 2 curve in the same graph automatically ( one for 2017 and one for 2018 ) 

DATESUM
06-oct-185
07-oct-182
  
06-oct-171
07-oct-175

thanks in advance

1 ACCEPTED SOLUTION
TomMartens
Super User
Super User

Hey,

 

yes it's possible to achieve this, but maybe not as simple as you might think 🙂

 

First I created a dedicated Calendar table (it's always a good idea to have a dedicated Calendar table in your data model) using this DAX statement:

Calendar = 
ADDCOLUMNS(
    CALENDAR("2017-01-01", "2018-12-31")
    ,"Year", YEAR(''[Date])
    ,"Month Day", FORMAT(''[Date],"MM-DD")
)

This is a very simple Calendar table, it just contains a date column, a Year column (this column will be used in the legend field of the line chart) and the "Month Day" (used as x-axis).

 

Then I created a relationship between both tables like so:

image.png

 

This allows to create a line chart like so:

image.png

 

 

Hopefully, this is what you are looking for!

 

Regards,

Tom 

 



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Do you know how to create a dynamic measure for trailing 3 months?   For example, in November, it would calculate Aug, Sept, Oct.....     and in Dec, it would calculate Sept, Oct, Nov.

 

 

Thanks!!!

TomMartens
Super User
Super User

Hey,

 

yes it's possible to achieve this, but maybe not as simple as you might think 🙂

 

First I created a dedicated Calendar table (it's always a good idea to have a dedicated Calendar table in your data model) using this DAX statement:

Calendar = 
ADDCOLUMNS(
    CALENDAR("2017-01-01", "2018-12-31")
    ,"Year", YEAR(''[Date])
    ,"Month Day", FORMAT(''[Date],"MM-DD")
)

This is a very simple Calendar table, it just contains a date column, a Year column (this column will be used in the legend field of the line chart) and the "Month Day" (used as x-axis).

 

Then I created a relationship between both tables like so:

image.png

 

This allows to create a line chart like so:

image.png

 

 

Hopefully, this is what you are looking for!

 

Regards,

Tom 

 



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

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.

Top Solution Authors