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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
madhav2020
Frequent Visitor

Maximum occuring unique value in a column

how to write a query to get maximum occuring unique value and its count in a column ?

 

Manager

Sujith

Ajay

Joseph

Sujith

Sujith

 

In the above table i would like to see answer as sujit-3 as it occurs maximum times

 

Quick help would be highly appretiated

1 ACCEPTED SOLUTION
AlB
Community Champion
Community Champion

Hi @madhav2020 

if you prefer to do it in DAX, you can create a  measure and place it in a card visual:

 

Measure 2 = 
VAR t_ = ADDCOLUMNS(DISTINCT(Table2[Manager]), "Count_", CALCULATE(COUNT(Table2[Manager])))
VAR max_ = MAXX(t_,[Count_])
RETURN 
CONCATENATEX(FILTER(t_, [Count_] = max_),[Manager]&"-"&[Count_],", ") 

 

Please mark the question solved when done and consider giving kudos 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

4 REPLIES 4
Smauro
Solution Sage
Solution Sage

Hi @madhav2020 

You could try adding a function and calling it based on your column:

    MaxCount = (l as list) =>
        let
            ToTable = Table.FromList(l, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
            Group = Table.Group(ToTable, {"Column1"}, {{"Count", each Table.RowCount(_), Int64.Type}}),
            Top = let n = List.Max( Group[Count]) in Table.CombineColumns(Table.TransformColumnTypes(Table.SelectRows(Group, each [Count] = n), {{"Count", type text}}),{"Column1", "Count"},Combiner.CombineTextByDelimiter(" - ", QuoteStyle.None),"Merged")[Merged]
        in
            if List.Count(Top) = 1 then Top{0} else Top,
    ManagersMax = MaxCount(PreviousStep[Manager])


Where PreviousStep is your previous step.

Note that it will return a text value if the top count of manager is unique, else it will return a list.

Cheers




Spyros Mavroforos

Data Consultant


Find me on LinkedIn or drop me an email

eSpyros

@Smauro Thanks for your effort but i was able to get an answer with the below DAX query which seems to be simple. But thanks again for your effort. Measure 2 = VAR t_ = ADDCOLUMNS(DISTINCT(Table2[Manager]), "Count_", CALCULATE(COUNT(Table2[Manager]))) VAR max_ = MAXX(t_,[Count_]) RETURN CONCATENATEX(FILTER(t_, [Count_] = max_),[Manager]&"-"&[Count_],", ")
AlB
Community Champion
Community Champion

Hi @madhav2020 

if you prefer to do it in DAX, you can create a  measure and place it in a card visual:

 

Measure 2 = 
VAR t_ = ADDCOLUMNS(DISTINCT(Table2[Manager]), "Count_", CALCULATE(COUNT(Table2[Manager])))
VAR max_ = MAXX(t_,[Count_])
RETURN 
CONCATENATEX(FILTER(t_, [Count_] = max_),[Manager]&"-"&[Count_],", ") 

 

Please mark the question solved when done and consider giving kudos if posts are helpful.

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

Cheers 

SU18_powerbi_badge

@AIB Thanks for the DAX query. It worked for my case. 🙂

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.

Top Solution Authors