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
MichaelaMul
Helper II
Helper II

Max Value group by or filter by other columns

Hi everyone!

 

I am trying to find the how many times Brand A has the most volume share in its category in each geography. In Power Query I separated Brand A from the other Products. Now I am trying to make a measure or a new column that calculates the following:

If Brand A Volume Share = Other Volume Share, Count 1, if not null. Or I would want to get the Max of the Other Volume Share of Segment by Category (excluding the overall volume share of 100%)

How would I do that? 

 

Sample data below: In blue is what I would like:

GeographyProduct Overall CategoryCategoryVolume Share of SegmentBrand A Volume Share of SegmentOther Volume Share of SegmentMAX OF Other Volume Share of SegmentCount where Brand A is the Max
Geo AProduct A AlmondAlmondAlmond202020  
Geo AProduct B AlmondAlmondAlmond50 5050 
Geo AProduct C AlmondAlmondAlmond30 30  
Geo AOverall AlmondAlmond 100    
Geo BProduct A AlmondAlmondAlmond606060601
Geo BProduct B AlmondAlmondAlmond30 30  
Geo BProduct C AlmondAlmondAlmond10 10  
Geo BOverall AlmondAlmond 100    
Geo AProduct A OatOatOat505060601
Geo AProduct B OatOatOat30 30  
Geo AProduct C OatOatOat20 20  
Geo AOverall OatOat 100    
Geo BProduct A OatOatOat606060601
Geo BProduct B OatOatOat25 25  
Geo BProduct C OatOatOat15 15  
Geo BOverall OatOat 100    
1 ACCEPTED SOLUTION
jgeddes
Super User
Super User

You can create two calculated columns 

Other Volume Share Max = 
var _max = 
CALCULATE(
        MAX([Other Volume Share of Segment]),
        ALLEXCEPT('Table', 'Table'[Geography], 'Table'[Category])
    )
var _result =
IF(
    _max = [Other Volume Share of Segment],
    _max,
    BLANK()
)
RETURN
_result
Count Brand A Max = 
var _max = 
CALCULATE(
        MAX([Volume Share of Segment]),
        ALLEXCEPT('Table', 'Table'[Geography], 'Table'[Category])
    )
var _result =
IF(
    AND([Brand A Volume Share of Segment] >= _max, [Category] <>""),
    1,
    0
)
RETURN
_result

And you will end up with...

jgeddes_0-1712693280040.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





View solution in original post

4 REPLIES 4
jgeddes
Super User
Super User

You can create two calculated columns 

Other Volume Share Max = 
var _max = 
CALCULATE(
        MAX([Other Volume Share of Segment]),
        ALLEXCEPT('Table', 'Table'[Geography], 'Table'[Category])
    )
var _result =
IF(
    _max = [Other Volume Share of Segment],
    _max,
    BLANK()
)
RETURN
_result
Count Brand A Max = 
var _max = 
CALCULATE(
        MAX([Volume Share of Segment]),
        ALLEXCEPT('Table', 'Table'[Geography], 'Table'[Category])
    )
var _result =
IF(
    AND([Brand A Volume Share of Segment] >= _max, [Category] <>""),
    1,
    0
)
RETURN
_result

And you will end up with...

jgeddes_0-1712693280040.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Hi again! I am trying to make now a total count for this by Director and or Manager in a card view and it isn't working. Do you know what measure I would use, I think it would be sum( Count Brand A Max), if Directors name is Tom or Jerry.

Using the sample data with, the following table connected to it, by Geography.

 

GeographyDirector ManagerDesired Count
Geo ATomBill1
Geo BTomBill2
Geo CTomBob 
Geo DTomNowell 
Geo EJerryJoe 
Geo FJerryDoe 
Geo GJerryDoe 

You can try this code as a calculated column in the geography table...

Sum of Table Count Brand A Max = 
var _currentGeo =
geoTable[Geography]
var _result =
SUMX(
    FILTER('Table', 'Table'[Geography] = _currentGeo),
    'Table'[Count Brand A Max]
)
RETURN
_result




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





thank you so much! that worked!

 

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.