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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
Anonymous
Not applicable

Count Based on Group

Dear All,

     I have a data like this,

Sample File is attached for your ref:  Sample PBIX

 

SalesReason.PNG

 

 

In this what I have already calculated is --> "The Maximum Sales". Referring to the above image, Maximum of Sales column is 7 out of 11 which is the total sales count. So, out of 11, i have maximum sales = 7. Refer the below measure used,

 

Maximum Sales = 
CONCATENATE (
    "Maximum Sales ",
    "(" & MAXX ( VALUES ( 'Table'[Sales] ), CALCULATE ( COUNT ( 'Table'[Sales] ) ) ) & " / "
        & COUNTROWS ( 'Table' ) & ")"
)

Now, What i wanted is, to get the each value of Reasons contributing to the Maximum Sales in a Card Visual. How can i achieve this in an easy way? Is there any other alternative way to achieve this in an wasy manner. Or, split this formula into separate parts I mean, the different measures for my easy understanding. Kindly request you to elaborate if possible that would be really helpful to me to understand what is going on each steps. Please help me. This is urgent.

 

Measure = 
CONCATENATEX (
    TOPN (
        1,
        SUMMARIZE (
            'Table',
            [Sales],
            'Table'[Reason],
            "Max Sales", COUNT ( 'Table'[Sales] )
        ),
        CALCULATE (
            MAXX ( VALUES ( 'Table'[Sales] ), CALCULATE ( COUNT ( 'Table'[Sales] ) ) ),
            ALLEXCEPT ( 'Table', 'Table'[Sales] )
        ), DESC
    ),
    [Max Sales] & " - " & [Reason],
    UNICHAR ( 10 ),
    [Max Sales], DESC
)

 

Thanks & Regards,

Praveen.

 

 

1 ACCEPTED SOLUTION
yelsherif
Resolver IV
Resolver IV

Here is a measure to solve your problem

 
Split =
var summaryTable = summarize(Table1,Table1[Sales],"count", count(Table1[ID]))
var salesName = FIRSTNONBLANK(SELECTCOLUMNS(filter(summaryTable,maxx(summaryTable,[count])),"Sales",[Sales]),true)
var theSplit = filter(summarize(Table1,Table1[Sales],Table1[Reason],"count", count(Table1[ID])),Table1[Sales]=salesName)
return
concatenatex(theSplit, [count] & " " & [Reason], ", ")

View solution in original post

2 REPLIES 2
yelsherif
Resolver IV
Resolver IV

Here is a measure to solve your problem

 
Split =
var summaryTable = summarize(Table1,Table1[Sales],"count", count(Table1[ID]))
var salesName = FIRSTNONBLANK(SELECTCOLUMNS(filter(summaryTable,maxx(summaryTable,[count])),"Sales",[Sales]),true)
var theSplit = filter(summarize(Table1,Table1[Sales],Table1[Reason],"count", count(Table1[ID])),Table1[Sales]=salesName)
return
concatenatex(theSplit, [count] & " " & [Reason], ", ")

I hope the measure worked for you, please accept it as a solution

Thanks

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.