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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
cmcgo3
Helper II
Helper II

Filtering Visual for Consecutive Years

I was given a solution back in February, but looking for additional options to resolve.

 

This is probably an easy fix, but I cannot figure out if I need a calculated column or DAX measure.  I do not get the result I want when applying a filter in visual (clustered bar chart).

I have Player 'A' and Player 'B' that participated in both Year 2022 and 2023.  Players 'C' only participated in 2023, while Player 'D' only particpated in 2022.  

I need a filter that excludes Players 'C' and 'D' because I only want to show players that particpated in consecutive years 2022 and 2023.

 

 

cmcgo3_0-1716331407110.png

 

 

 

 

 

  filter.pbix 

1 ACCEPTED SOLUTION

@cmcgo3 

pls try this

Column =
var _last=maxx(FILTER('Table','Table'[player]=EARLIER('Table'[player])&&'Table'[year]=EARLIER('Table'[year])-1),'Table'[year])
VAR _next=maxx(FILTER('Table','Table'[player]=EARLIER('Table'[player])&&'Table'[year]=EARLIER('Table'[year])+1),'Table'[year])
VAR _currentyear=maxx(FILTER('Table','Table'[player]=EARLIER('Table'[player])&&'Table'[year]=year(today())),'Table'[year])
return if(ISBLANK(_currentyear),BLANK(),if(not(ISBLANK(_last))||not(ISBLANK(_next)),"y"))
 
pls see the attachment below




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

5 REPLIES 5
ryan_mayu
Super User
Super User

@cmcgo3 

pls try to create a column

Column =
var _last=maxx(FILTER('Table','Table'[player]=EARLIER('Table'[player])&&'Table'[year]=EARLIER('Table'[year])-1),'Table'[year])
VAR _next=maxx(FILTER('Table','Table'[player]=EARLIER('Table'[player])&&'Table'[year]=EARLIER('Table'[year])+1),'Table'[year])
return if (not(ISBLANK(_last))||not(ISBLANK(_next)),"y")
 
11.PNG12.PNG
 
 
pls see the attachemnt below




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Thank you Ryan, it works just like it is written.  I need one small edit though, If i want the max year to = 2024 which should return all blanks, how would I adjust this calculation?? Thanks!!

what do you mean by max year to 2024? if has Consecutive Years until 2024, then all be blank?

could you pls update the sample data and expected output?





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Hello Ryan,  I went in and added Year 2024 for Player A, Player C, and Player D.  Now in visual, Player A, B, and C are showing.  Because the way the column is written, Player B shows up because of the year 2023 and 2022.  Since the current year is 2024, I only want Player A and Player C to show up on chart.  I was wondering what next step would be to adjust your column you created?  I hope I explained well...

 

https://1drv.ms/u/s!AuqlAZe1G3j7lUmnTs0wRdND6YoQ?e=MODoUS 

@cmcgo3 

pls try this

Column =
var _last=maxx(FILTER('Table','Table'[player]=EARLIER('Table'[player])&&'Table'[year]=EARLIER('Table'[year])-1),'Table'[year])
VAR _next=maxx(FILTER('Table','Table'[player]=EARLIER('Table'[player])&&'Table'[year]=EARLIER('Table'[year])+1),'Table'[year])
VAR _currentyear=maxx(FILTER('Table','Table'[player]=EARLIER('Table'[player])&&'Table'[year]=year(today())),'Table'[year])
return if(ISBLANK(_currentyear),BLANK(),if(not(ISBLANK(_last))||not(ISBLANK(_next)),"y"))
 
pls see the attachment below




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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