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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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
smignogna
Frequent Visitor

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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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