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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
Anonymous
Not applicable

How to find the minimum of average column based on another column.

Hi. I have 2 columns here. Column 'Name' and column 'Sales'.

I would like to find the minimum of average Sales based on each type of Name. And I want to return the name ( because I have 2 visual cards. One showing the value, another one showing the name of minimum average sales) 

zhrhr_0-1608810770844.png

 

2 ACCEPTED SOLUTIONS
AlB
Community Champion
Community Champion

@Anonymous 

NameM V2 =
MAXX (
    TOPN ( 1, DISTINCT ( Table1[Name] ), CALCULATE ( SUM ( Table1[Sales] ) ), ASC ),
    [Name]
)
SalesM V2 =
MINX ( DISTINCT ( Table1[Name] ), CALCULATE ( SUM ( Table1[Sales] ) ) )

And I just reread and see that you need the average? If so use AVERAGE instead of of SUM

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

 

SU18_powerbi_badge

View solution in original post

AlB
Community Champion
Community Champion

@Anonymous 

You need to consider name and surname together.  Otherwise you are grouping and calculating the average by name only or by surname only. I guess that is not what you need.

 

Best SurName V2 =
MAXX (
    TOPN (
        1,
        SUMMARIZE ( Sheet1, Sheet1[SURNAME], Sheet1[NAME] ),
        CALCULATE ( AVERAGE ( Sheet1[SALE] ) ), ASC
    ),
    [SURNAME]
)
Best Name V2 =
MAXX (
    TOPN (
        1,
        SUMMARIZE ( Sheet1, Sheet1[SURNAME], Sheet1[NAME] ),
        CALCULATE ( AVERAGE ( Sheet1[SALE] ) ), ASC
    ),
    [NAME]
)
Best Sales V2 =
MINX (
    SUMMARIZE ( Sheet1, Sheet1[SURNAME], Sheet1[NAME] ),
    CALCULATE ( AVERAGE ( Sheet1[SALE] ) )
)

 

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

 

SU18_powerbi_badge

View solution in original post

10 REPLIES 10
AlB
Community Champion
Community Champion

@Anonymous 

Not unless I see a proper data sample or pbix clearly showing what the issue is

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

 

SU18_powerbi_badge

 

Anonymous
Not applicable

Hey @AlB  This is my link to the pbix file. I also show the bar chart. The answer should show the lowest value on the card where for the year 2020, the Name is supposed to be Irong 7, surname PAC R with the value of 347.70 

https://1drv.ms/u/s!AoKh3nlpMpSOgl7cRjhFOqfXmMv8?e=mWghoq

Really appreciate it if you could help me with this.

AlB
Community Champion
Community Champion

@Anonymous 

I don't understand. Those values are exactly what your measures are showing in the attached file. What is the problem?

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

 

SU18_powerbi_badge

 

Anonymous
Not applicable

@AlB I should be getting PAC R. But I'm getting PAC N instead. Am I wrong anywhere?

 

AlB
Community Champion
Community Champion

@Anonymous 

You need to consider name and surname together.  Otherwise you are grouping and calculating the average by name only or by surname only. I guess that is not what you need.

 

Best SurName V2 =
MAXX (
    TOPN (
        1,
        SUMMARIZE ( Sheet1, Sheet1[SURNAME], Sheet1[NAME] ),
        CALCULATE ( AVERAGE ( Sheet1[SALE] ) ), ASC
    ),
    [SURNAME]
)
Best Name V2 =
MAXX (
    TOPN (
        1,
        SUMMARIZE ( Sheet1, Sheet1[SURNAME], Sheet1[NAME] ),
        CALCULATE ( AVERAGE ( Sheet1[SALE] ) ), ASC
    ),
    [NAME]
)
Best Sales V2 =
MINX (
    SUMMARIZE ( Sheet1, Sheet1[SURNAME], Sheet1[NAME] ),
    CALCULATE ( AVERAGE ( Sheet1[SALE] ) )
)

 

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

 

SU18_powerbi_badge

Anonymous
Not applicable

YES! Thank you so much!

AlB
Community Champion
Community Champion

@Anonymous 

NameM V2 =
MAXX (
    TOPN ( 1, DISTINCT ( Table1[Name] ), CALCULATE ( SUM ( Table1[Sales] ) ), ASC ),
    [Name]
)
SalesM V2 =
MINX ( DISTINCT ( Table1[Name] ), CALCULATE ( SUM ( Table1[Sales] ) ) )

And I just reread and see that you need the average? If so use AVERAGE instead of of SUM

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

 

SU18_powerbi_badge

Anonymous
Not applicable

Thanks for replying! I was actually needed this formula to find for SURNAME too 

NameM V2 =
MAXX (
    TOPN ( 1, DISTINCT ( Table1[SurName] ), CALCULATE ( SUM ( Table1[Sales] ) ), ASC ),
    [SurName]
)

and when I create this measure, It does not show the correct value. And I was wondering why. But if I replace ASC with DESC (just to check the opposite value for the lowest, it shows the correct max average for that surname)

Do you have any other way to solve this?

AlB
Community Champion
Community Champion

Hi @Anonymous 

NameM =
MAXX (
    TOPN ( 1, DISTINCT ( Table1[Name] ), CALCULATE ( SUM ( Table1[Sales] ) ) ),
    [Name]
)

 

SalesM =
MAXX ( DISTINCT ( Table1[Name] ), CALCULATE ( SUM ( Table1[Sales] ) ) )

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

 

SU18_powerbi_badge

 

Anonymous
Not applicable

That formula works perfectly. But it was showing the highest value. I want the lowest value. Which part should I change?

 

I change MAXX to MINX but it only works for the Sales. The Name doesn't change, it still showing the largest 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.