Forum Discussion
Need Help: Dynamic Filtering in Power BI: Show All Relevant Items Beyond Initial Top 8
- Anonymous1 year ago
Hi BaSan ,
Here I create a sample to show you how to achieve your goal. I think you can try ISFILTERED() and IF() function.
Dynamic TopN for Country = VAR _TopN = IF ( MAX ( 'Table'[Country] ) IN SUMMARIZE ( TOPN ( 8, SUMMARIZE ( ALLSELECTED ( 'Table' ), 'Table'[Country], "Count", CALCULATE ( SUM ( 'Table'[Value] ) ) ), [Count], DESC ), [Country] ), 1, 0 ) RETURN IF ( ISFILTERED ( 'Table'[Country] ), 1, _TopN )Dynamic TopN for Sector = VAR _TopN = IF ( MAX ( 'Table'[Sector] ) IN SUMMARIZE ( TOPN ( 8, SUMMARIZE ( ALLSELECTED ( 'Table' ), 'Table'[Sector], "Count", CALCULATE ( SUM ( 'Table'[Value] ) ) ), [Count], DESC ), [Sector] ), 1, 0 ) RETURN IF ( ISFILTERED ( 'Table'[Country] ), 1, _TopN )Add above measure into Country/Sector visual and set it to show items when value = 1.
Since I have less data in my sample, I show Top1. So when by default it will show Top1 in Country/Sector visual.
When I select C3 in country, the Sector visual will show all sector in this coutry.
When I select S2 in Sector, the Coutry visual will show all country in this sector.
Best Regards,
Rico ZhouIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi BaSan ,
Here I create a sample to show you how to achieve your goal. I think you can try ISFILTERED() and IF() function.
Dynamic TopN for Country =
VAR _TopN =
IF (
MAX ( 'Table'[Country] )
IN SUMMARIZE (
TOPN (
8,
SUMMARIZE (
ALLSELECTED ( 'Table' ),
'Table'[Country],
"Count", CALCULATE ( SUM ( 'Table'[Value] ) )
),
[Count], DESC
),
[Country]
),
1,
0
)
RETURN
IF ( ISFILTERED ( 'Table'[Country] ), 1, _TopN )Dynamic TopN for Sector =
VAR _TopN =
IF (
MAX ( 'Table'[Sector] )
IN SUMMARIZE (
TOPN (
8,
SUMMARIZE (
ALLSELECTED ( 'Table' ),
'Table'[Sector],
"Count", CALCULATE ( SUM ( 'Table'[Value] ) )
),
[Count], DESC
),
[Sector]
),
1,
0
)
RETURN
IF ( ISFILTERED ( 'Table'[Country] ), 1, _TopN )
Add above measure into Country/Sector visual and set it to show items when value = 1.
Since I have less data in my sample, I show Top1. So when by default it will show Top1 in Country/Sector visual.
When I select C3 in country, the Sector visual will show all sector in this coutry.
When I select S2 in Sector, the Coutry visual will show all country in this sector.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.