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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
ROCKYDO12
Helper III
Helper III

Dynamic Top N by Fiscal Year

I am trying to create a Dynamic slicer for all my charts and tables on my power bi dashboard so the user can enter in a TopN for Fiscal Year and it will filter the charts so that it shows the top fiscal years. So for example if a user wanted to see the last 10 fiscal years in the bar chart, they would enter 10 in the slicer and it will give them their desired results. I have tried to follow along to the below article and have created a Top N parmater but im getting stuck after that. Note sure how I can tie the Top N to my Fiscal Year I am using in my tables and charts.

 

https://community.powerbi.com/t5/Community-Blog/Dynamic-TopN-made-easy-with-What-If-Parameter/ba-p/3...

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@ROCKYDO12 , if you have not selected a year

 

This year Today =
var _max = maxx(allselected('Date'), 'Date'[FY] )  //assume FY is number else have Rank on FY

var _min = _max -10
return
CALCULATE([Net], FILTER('Date','Date'[FY] >=_min && 'Date'[FY] <= _max))

 

 

rank column

Year Rank = RANKX(all('Date'),'Date'[FY Year Start date],,ASC,Dense)

 

Measure =

var _max = maxx(allselected('Date'), 'Date'[Year Rank] )  //assume FY is number else have Rank on FY

var _min = _max -10
return
CALCULATE([Net], FILTER('Date','Date'[Year Rank] >=_min && 'Date'[Year Rank] <= _max))


In case you have selected year then you an independent table for slicer

 

//Date1 is independent Date table, Date is joined with Table
new measure =
var _max = maxx(allselected(Date1),Date1[FY])
var _min = _max -10
return
calculate( sum(Table[Value]), filter('Date', 'Date'[FY] >=_min && 'Date'[FY] <=_max))

 

Need of an Independent Date Table:https://www.youtube.com/watch?v=44fGGmg9fHI

 

Power BI — Year on Year with or Without Time Intelligence
https://medium.com/@amitchandak.1978/power-bi-ytd-questions-time-intelligence-1-5-e3174b39f38a
https://www.youtube.com/watch?v=km41KfM_0uA

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

1 REPLY 1
amitchandak
Super User
Super User

@ROCKYDO12 , if you have not selected a year

 

This year Today =
var _max = maxx(allselected('Date'), 'Date'[FY] )  //assume FY is number else have Rank on FY

var _min = _max -10
return
CALCULATE([Net], FILTER('Date','Date'[FY] >=_min && 'Date'[FY] <= _max))

 

 

rank column

Year Rank = RANKX(all('Date'),'Date'[FY Year Start date],,ASC,Dense)

 

Measure =

var _max = maxx(allselected('Date'), 'Date'[Year Rank] )  //assume FY is number else have Rank on FY

var _min = _max -10
return
CALCULATE([Net], FILTER('Date','Date'[Year Rank] >=_min && 'Date'[Year Rank] <= _max))


In case you have selected year then you an independent table for slicer

 

//Date1 is independent Date table, Date is joined with Table
new measure =
var _max = maxx(allselected(Date1),Date1[FY])
var _min = _max -10
return
calculate( sum(Table[Value]), filter('Date', 'Date'[FY] >=_min && 'Date'[FY] <=_max))

 

Need of an Independent Date Table:https://www.youtube.com/watch?v=44fGGmg9fHI

 

Power BI — Year on Year with or Without Time Intelligence
https://medium.com/@amitchandak.1978/power-bi-ytd-questions-time-intelligence-1-5-e3174b39f38a
https://www.youtube.com/watch?v=km41KfM_0uA

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Jan NL Carousel

Fabric Community Update - January 2025

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