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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Zaky
Helper IV
Helper IV

Need Help

Hi

 

I have created a line chart where it can compare the trends for 2 years.

For this line chart, I want it to remain trending for 2 years without changing either if I choose any reporting year.

How can I do this?

 

For Axis fields I selected = Reported Date

For Legend fields I selected - Reported Date and change it by date hierarchy

For the Value fields I created a measure = 

CALCULATE(COUNT('Master'[Incident ID]),DATEADD('Master'[Reported Date].[Date],0,YEAR))
 
all.PNG  
 
My expectation for the Incident Trend line chart i like this
trend for 2 years.PNG
 Really appreciate if someone can help me.
 
Thanks.
 
1 ACCEPTED SOLUTION
halfglassdarkly
Responsive Resident
Responsive Resident

Hi Zaky, you can disable the effect of the year slicer on that visual.

 

  • Under format click on Edit Interactions
  • Select your year slicer (click on the bounding box)
  • Click on the None filter icon (circle with diagonal strike through) for the visual that you don't want filtered by the slicer.
  • Click the Edit Interactions button again to exit edit mode

 

halfglassdarkly_0-1632023153656.png

halfglassdarkly_1-1632023233402.png

 

You can then either filter your visual manually to the years you want using the filter pane, or do this dynamically.

 

Assuming you have a column for year in your table which you're using for your legend, you could use something like this to filter your measure to current + previous year.

 

Measure =
//create variable to store current year
Var CurrentYear = year(now())
RETURN
if(max('Master'[Year]) in{CurrentYear,CurrentYear-1},CALCULATE(COUNT('Master'[Incident ID])))

View solution in original post

2 REPLIES 2
halfglassdarkly
Responsive Resident
Responsive Resident

Hi Zaky, you can disable the effect of the year slicer on that visual.

 

  • Under format click on Edit Interactions
  • Select your year slicer (click on the bounding box)
  • Click on the None filter icon (circle with diagonal strike through) for the visual that you don't want filtered by the slicer.
  • Click the Edit Interactions button again to exit edit mode

 

halfglassdarkly_0-1632023153656.png

halfglassdarkly_1-1632023233402.png

 

You can then either filter your visual manually to the years you want using the filter pane, or do this dynamically.

 

Assuming you have a column for year in your table which you're using for your legend, you could use something like this to filter your measure to current + previous year.

 

Measure =
//create variable to store current year
Var CurrentYear = year(now())
RETURN
if(max('Master'[Year]) in{CurrentYear,CurrentYear-1},CALCULATE(COUNT('Master'[Incident ID])))

@halfglassdarkly 

 

Wonderful! I got what i needed.

Thank you very much for your help.

 

Best regards.

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.