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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

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
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!

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.