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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
lilynguyen
Frequent Visitor

how to highlight top n value in table visual and change based on slicer

yDear,

I have a detailed data table like this

WarehouseOrder IDweightDateOver / not
A1121/2/2002Over
B2351/2/2002Not
C3761/2/2002Not
D4851/2/2002Over
E5921/2/2002Over
A6322/2/2020Over
B7952/2/2020Not
D812/2/2020Over
D932/2/2020Over
C1052/2/2020Not

 

And I created a table visual on report, like this:

WarehouseTotal order IDTotal weight
B2130
E192
D389
C181
A244

 

I can highlight top 3 if I don't add any slicer on report.
When I add some slicer on report, like: Date Filter, Over / not Filter,... I tried to use RankX but when I choose Selected all on any filter, it doesn't work as I think.

Any solution idea for me?
Thanks.






1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@lilynguyen , Create TOPN Measure an then create a colot measure on top of it

https://youtu.be/QIVEFp-QiOk

 

Top 3 City Rank = CALCULATE([Sales],TOPN(3,all(Geography[City]),[Sales],DESC),VALUES(Geography[City Id]))

 

color = if(isblank([Top 3 City Rank]), "white", "green")

 

use it conditional formtting using "field" in coditional formatting

https://radacad.com/dax-and-conditional-formatting-better-together-find-the-biggest-and-smallest-num...
https://docs.microsoft.com/en-us/power-bi/desktop-conditional-table-formatting#color-by-color-values

View solution in original post

2 REPLIES 2
v-yangliu-msft
Community Support
Community Support

Hi  @lilynguyen ,

Here are the steps you can follow:

1. Create measure.

Total weight_sample =
SUM('Table'[weight])
rank =
RANKX(ALLSELECTED('Table'),[Total weight_sample],,DESC)
Total order ID =
var _count= COUNT('Table'[Order ID])
return
IF(HASONEFILTER('Table'[Over / not])||HASONEFILTER('Table'[Date]),
_count,
IF([rank]<=3,_count,BLANK()))
Total weight =
IF(HASONEFILTER('Table'[Over / not])||HASONEFILTER('Table'[Date]),
[Total weight_sample],
IF([rank]<=3,[Total weight_sample],BLANK()))

2. Put the total order ID and total weight in the table

3. Result.

v-yangliu-msft_0-1608017800056.png

You can downloaded PBIX file from here.

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@lilynguyen , Create TOPN Measure an then create a colot measure on top of it

https://youtu.be/QIVEFp-QiOk

 

Top 3 City Rank = CALCULATE([Sales],TOPN(3,all(Geography[City]),[Sales],DESC),VALUES(Geography[City Id]))

 

color = if(isblank([Top 3 City Rank]), "white", "green")

 

use it conditional formtting using "field" in coditional formatting

https://radacad.com/dax-and-conditional-formatting-better-together-find-the-biggest-and-smallest-num...
https://docs.microsoft.com/en-us/power-bi/desktop-conditional-table-formatting#color-by-color-values

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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