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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
ngct1112
Post Patron
Post Patron

Sub-total - Most COUNT value in the group

Hi All,

 

I am trying hard to find a way to achieve my desired result.

In this group, 

Supplier A: occur 4 times

Supplier C: occur 1 time

Supplier E: occur 1 time

 

I am hoping the Sub-total can show the most frequent supplier, which means "A"

ngct1112_1-1627622053046.png

Please refer to the Sample BI 

Since "Supplier 1" itself is a measure, I know it will be a little tricky. 

Appreciated if I could get any help from here.

 

For more information, what I am trying to do is to create a table to show the users which suppliers with the lowest cost across all suppliers for each QTY .

 

 

1 ACCEPTED SOLUTION
v-angzheng-msft
Community Support
Community Support

Hi, @ngct1112 

 

1. To create a calculated table:

subT = 
var _t1=SUMMARIZE('Table',[Quantity From],"Su",[Supplier 1])
return _t1

2. To create 5 measures

__isP1 = ISFILTERED('Table'[Product Type])
__isP2 = ISFILTERED('Table'[Quantity From])
P1+P2 = [__isP1]+[__isP2]
__maxCountSu = 
var _t=MAXX(TOPN(1,SUMMARIZE('subT',[Su],"count",COUNTX('subT',[Su])),[count]),[Su])
return _t
__Supplier 1.1 = 
SWITCH(
    [P1+P2],
    1,[__maxCountSu],[Supplier 1])

Then the result would be like this:

vangzhengmsft_0-1627979424969.png

Please refer to the attachment below for details

 

 

Hope this helps.

 

Best Regards,
Community Support Team _ Zeon Zheng
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-angzheng-msft
Community Support
Community Support

Hi, @ngct1112 

 

1. To create a calculated table:

subT = 
var _t1=SUMMARIZE('Table',[Quantity From],"Su",[Supplier 1])
return _t1

2. To create 5 measures

__isP1 = ISFILTERED('Table'[Product Type])
__isP2 = ISFILTERED('Table'[Quantity From])
P1+P2 = [__isP1]+[__isP2]
__maxCountSu = 
var _t=MAXX(TOPN(1,SUMMARIZE('subT',[Su],"count",COUNTX('subT',[Su])),[count]),[Su])
return _t
__Supplier 1.1 = 
SWITCH(
    [P1+P2],
    1,[__maxCountSu],[Supplier 1])

Then the result would be like this:

vangzhengmsft_0-1627979424969.png

Please refer to the attachment below for details

 

 

Hope this helps.

 

Best Regards,
Community Support Team _ Zeon Zheng
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-angzheng-msft 

though totally have no idea how it happens, it works fine in the model.

Great thanks for your brillant solution.

amitchandak
Super User
Super User

@ngct1112 , Try TOPN, I am assuming it should work at sub total level too

 

CALCULATE(max(Data[Supplier]),TOPN(1,allselected(Data[Supplier]),[Supplier cost],DESC),VALUES(Data[Supplier]))

 

 

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi @amitchandak , I tried to apply this formual but not working. Attached as Sample BI 

ngct1112_0-1627623902826.png

Please be reminded that

1. "Unit Price_FX" itself is a meaure.

2. "Supplier 1" is referring to the lowest cost supplier, filtered by a "Rank = 1" measure

Rank by Supplier = 
RANKX(
   FILTER(
       ALLSELECTED('Table'[Group],'Table'[Supplier]),
       'Table'[Group]=MAX('Table'[Group])),
       [UnitPrice_FX],,ASC)

 

Appreciated if there is any solution.

 

 

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

Feb2025 NL Carousel

Fabric Community Update - February 2025

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

Top Kudoed Authors