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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
phjz
Frequent Visitor

Last 12 Months Ranking based on filtered value

Hey guys,

 

is it possible to extract the related date value from a filtered field to show a ranking within the last 12 months from this given date?

 

Let's say I have a table called "table1" and in this table is a column called "title" and a column called "date". Within the report, I want to use this title column in a slicer. In the same report page, I want to have a ranking table visual with titles and a KPI measure. I want the ranker to show the top 20 titles (based on the KPI measure) within the last 12 months, starting from the related date value from the filtered title.

 

But when I do this without further DAX, the ranker only shows the filtered entry. Is there a possibility to do that?

 

Thanks!

2 ACCEPTED SOLUTIONS
bhanu_gautam
Super User
Super User

@phjz Ensure you have a date table in your model. If not, create one.

 

Create a measure that calculates your KPI.

 

Create a measure that calculates the ranking based on the KPI measure within the last 12 months.

DAX
KPI Measure =
-- Replace this with your actual KPI calculation
SUM('table1'[KPI])

Ranking Measure =
VAR SelectedDate = MAX('table1'[date])
VAR StartDate = EDATE(SelectedDate, -12)
VAR FilteredTable =
FILTER(
ALL('table1'),
'table1'[date] >= StartDate &&
'table1'[date] <= SelectedDate
)
RETURN
RANKX(
FilteredTable,
[KPI Measure],
,
DESC,
DENSE
)

 

Add a slicer to your report using the title column.

Add a table visual to your report and include the title, date, and the Ranking Measure.

Apply a filter to the table visual to show only the top 20 titles based on the Ranking Measure




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






View solution in original post

Hi @phjz,

Thank you for posting your query in the Microsoft Fabric Community Forum, and thanks to @bhanu_gautam for sharing valuable insights.

After thoroughly reviewing the details you provided, When you use a slicer, it applies a filter directly to the visual. Visual-level filters take precedence and override any broader filtering logic you might define in a measure or calculated table, this will make the results limited to slicer selection.

If this information is helpful, please “Accept it as a solution” and give a "kudos" to assist other community members in resolving similar issues more efficiently.
Thank you.

View solution in original post

7 REPLIES 7
v-ssriganesh
Community Support
Community Support

Hi @phjz,

May I ask if you have resolved this issue? If so, please mark it as the solution. This will be helpful for other community members who have similar problems to solve it faster.

Thank you.

v-ssriganesh
Community Support
Community Support

Hi @phjz,
Could you please confirm if your query have been resolved by the solution provided by? If so, please mark it as the solution. This will be helpful for other community members who have similar problems to solve it faster.

Thank you.

phjz
Frequent Visitor

Has anyone an idea? The measure provided by @bhanu_gautam works fine, but the slicer within the report still filters the whole table, so hat it shows only the filtered title...

 

Thanks!

Hi @phjz,

Thank you for posting your query in the Microsoft Fabric Community Forum, and thanks to @bhanu_gautam for sharing valuable insights.

After thoroughly reviewing the details you provided, When you use a slicer, it applies a filter directly to the visual. Visual-level filters take precedence and override any broader filtering logic you might define in a measure or calculated table, this will make the results limited to slicer selection.

If this information is helpful, please “Accept it as a solution” and give a "kudos" to assist other community members in resolving similar issues more efficiently.
Thank you.

Hi @phjz,

I hope this information is helpful. Please let me know if you have any further questions or if you'd like to discuss this further. If this answers your question, please accept it as a solution and give it a 'Kudos' so other community members with similar problems can find a solution faster.
Thank you.

bhanu_gautam
Super User
Super User

@phjz Ensure you have a date table in your model. If not, create one.

 

Create a measure that calculates your KPI.

 

Create a measure that calculates the ranking based on the KPI measure within the last 12 months.

DAX
KPI Measure =
-- Replace this with your actual KPI calculation
SUM('table1'[KPI])

Ranking Measure =
VAR SelectedDate = MAX('table1'[date])
VAR StartDate = EDATE(SelectedDate, -12)
VAR FilteredTable =
FILTER(
ALL('table1'),
'table1'[date] >= StartDate &&
'table1'[date] <= SelectedDate
)
RETURN
RANKX(
FilteredTable,
[KPI Measure],
,
DESC,
DENSE
)

 

Add a slicer to your report using the title column.

Add a table visual to your report and include the title, date, and the Ranking Measure.

Apply a filter to the table visual to show only the top 20 titles based on the Ranking Measure




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Thank you so much for your quick reply!

 

I implemented your measure and the rankx gives me the right ranking per title. But there is still one problem: When I choose a title with my slicer, it still filters the whole table so that I only can see the filtered title and its ranking. But I still want to see all top 20 titles. Is this possible?

Thanks!

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

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.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.