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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
mmarchioni
Helper I
Helper I

Need to show rows associated with last 2 dates per subject

I am trying to show only the rows associated with the last two dates per subject:

 

mmarchioni_0-1683130611625.png

 

When I try the Top N filter with2, it gives me only the most recent two dates for all subjects.

Help, please.

3 REPLIES 3
amitchandak
Super User
Super User

@mmarchioni , Try new window function

 

TOPN using window = Sumx(KEEPFILTERS(Window(1,ABS,2,ABS, ALLSELECTED('Table'[Subject],'Table'[Date]),ORDERBY('Table'[Date],Desc),,PARTITIONBY('Table'[Subject]))), calculate(Countrows(Table)))

 

 

Learn Power BI: Dynamic TOPN using TOPN/Window and Numeric parameter: https://youtu.be/vm2mdEioQPQ

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

From the questions you have posted it appears we are pulling the same kind of data. It would be interesting to chat and see what you have verse what I have and see if possibly we can help each other. There isn't many of us HLA data peoples out there:-)

Unfortunately I have an older version of PowerBI (pre WINDOW fundtion) and can't upgrade yet. Is there another formula I can try?

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Kudoed Authors