Forum Discussion
Last 12 Months Ranking based on filtered value
- 1 year ago
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
- 1 year ago
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.
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
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!