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

Return Second highest value from a summarize Table

Hi, 

 

I have a requirement where I want values of products which had first and second highest reviews. For getting the product which has the highest number of reviews I am using the following Dax Query: 

 

Positive_Theme_1 =
MAXX(
TOPN(
1,
SUMMARIZE('00. ITC_Comment','00. ITC_Comment'[theme_1],"Count", CALCULATE('4. Comments_Measures'[review count],'00. ITC_Comment'[comment_sentiment_value] ="Positive")),
[count],DESC),
[theme_1]
)
 
Summary table also looks like below:
 
theme_1Count
Taste/flavour46867
Quantity3495
Mfg. & Expiry115
Price1161
Packaging231
Quality3911
Miscellaneous178
Delivery3907
Platform Services82
Genuineness524
health33
Stock Availability 
Gifting 
Usability 
Duplicate Pack 
Expiry 
Missing Material 
Hygiene1

 

the first dax query that I have given above returns "Taste/flavour". Now if I want second and third themes based on the count, how should I update the Query. is there any way to get this through Dax. 

2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@Jagan_MFilterIT , Create measure like these

 

Measure = CALCULATE('4. Comments_Measures'[review count],filter('00. ITC_Comment','00. ITC_Comment'[comment_sentiment_value] ="Positive"))

 

Rank = rankx(allselected('00. ITC_Comment','00. ITC_Comment'[theme_1]), [measure],,desc,dense)

 

Rank 2= sumx(filter(values('00. ITC_Comment','00. ITC_Comment'[theme_1]), [Rank] =2), [Measure])

 

either you can filter Rank at visual or use a measure like Rank 2

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

View solution in original post

@Jagan_MFilterIT , Try like

Rank 2= maxx(filter(values('00. ITC_Comment','00. ITC_Comment'[theme_1]), [Rank] =2), [theme_1])

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

View solution in original post

4 REPLIES 4

Thanks a lot Sir, This worked! 

amitchandak
Super User
Super User

@Jagan_MFilterIT , Create measure like these

 

Measure = CALCULATE('4. Comments_Measures'[review count],filter('00. ITC_Comment','00. ITC_Comment'[comment_sentiment_value] ="Positive"))

 

Rank = rankx(allselected('00. ITC_Comment','00. ITC_Comment'[theme_1]), [measure],,desc,dense)

 

Rank 2= sumx(filter(values('00. ITC_Comment','00. ITC_Comment'[theme_1]), [Rank] =2), [Measure])

 

either you can filter Rank at visual or use a measure like Rank 2

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

Hi Sir, 

 

Thanks a lot for the reply. The Rank2 formula given above gives the numeric value of the row "3495" but I want the corresponding theme(label) = "Quantity". Is there a way to get it

 

@Jagan_MFilterIT , Try like

Rank 2= maxx(filter(values('00. ITC_Comment','00. ITC_Comment'[theme_1]), [Rank] =2), [theme_1])

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

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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