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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
priyapalanki
Frequent Visitor

Comparing previous and current year data on a line chart

Hi

 

I want to compare the daily trend for FY 16 ( Jul 1st 2015 to June 30th 2016) and FY17( July 1st 2016 to June 30th 2017) on a line chart in two graphs ,  on the x-axis I want to see only the month and when I hover over the graph i want to see the daily values . The legend should dispaly Fiscal Year (FY16 , FY17).

Can someone help me pn how to accomplish this scenario ?

 

Thanks,

Priya

 

 

1 ACCEPTED SOLUTION

Hi @priyapalanki,

 

if you have 2 separate tables FY16 and FY17, it's easy now.

 

Dates = CALENDARAUTO()

 

  • Create Prev-Date Column
Prev - Date = DATEADD( Dates[Date],-1,YEAR)

 

  • Union 2 separate tables FY16 -FY17 into 1 table: 
u = UNION(FY16,FY17)
  • Create 2 calculated measure to cumpute total amount of FY16 and FY17:
FY16 = CALCULATE(SUM(u[Amount]),FILTER(all(dates),Dates[Date]=MAX(Dates[Prev - Date]) ))
FY17 = CALCULATE(SUM(u[Amount]),FILTER(all(dates),[FY16]>0 && Dates[Date]=max(Dates[Date])  ))

 

Screenshot 2017-01-15 13.48.19.png

 

 

My sample data and sample pbix file

 

 

If this works for you please accept it as solution and also like to give KUDOS.

Best regards
Tri Nguyen

View solution in original post

5 REPLIES 5
tringuyenminh92
Memorable Member
Memorable Member

Hi @priyapalanki,

 

Do you have any sample data or data structure? so I could quicky try to figure out solution.Smiley Very Happy

@tringuyenminh92 : Hi , this is my sample data for FY16 .

 

TestData.JPG

 

Here is the visualization on the line chart using the above data. Right now on the axis , it is showing the month and year. When I hover over the graph I see the daily values.

 

 

Visual.jpg

I have another table for FY17 similar to FY16 . Now I want to show the FY17 data on the same chart above the FY16 graph . On the axis , I want to see only the month . On the legend I want to see FY16 and FY17.

 

Please help me in accomplishing this. Thanks.

 

Priya

 

 

 

 

 

Hi @priyapalanki,

 

if you have 2 separate tables FY16 and FY17, it's easy now.

 

Dates = CALENDARAUTO()

 

  • Create Prev-Date Column
Prev - Date = DATEADD( Dates[Date],-1,YEAR)

 

  • Union 2 separate tables FY16 -FY17 into 1 table: 
u = UNION(FY16,FY17)
  • Create 2 calculated measure to cumpute total amount of FY16 and FY17:
FY16 = CALCULATE(SUM(u[Amount]),FILTER(all(dates),Dates[Date]=MAX(Dates[Prev - Date]) ))
FY17 = CALCULATE(SUM(u[Amount]),FILTER(all(dates),[FY16]>0 && Dates[Date]=max(Dates[Date])  ))

 

Screenshot 2017-01-15 13.48.19.png

 

 

My sample data and sample pbix file

 

 

If this works for you please accept it as solution and also like to give KUDOS.

Best regards
Tri Nguyen

@tringuyenminh92 Thanks a lot for providing the solution . Would it be possible to see only the month on the axis ?

 

SampleNew.JPG

Hi @priyapalanki,

 

As formula of 2 calcuated measure, it's computing by date level to show daily value in line chart, so far i could not make the X-Axis to show month level.  It's so sorry to say that in this moment. Smiley Sad

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.