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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

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
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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