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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Winning Percentage by grouping in DAX

Hi, 

I have the following data with me:

Ritindeep_0-1639115523759.png


And I want to basically show each controller with status having max lives and percent as below:

ControllerWinning Percent
Zing HealthUnknown (45.60%)
YamHill County Care organizationUnknown (50.33%)
Yale HealthUnknown (54/05%)

 

This basically shows that for a controller, Unknown status has the maximum StateLives and the percentage value in brackets depicts its percentage with that controller among all other status. 
i.e. For Zing health , Unknown status has max lives of 151335 and its coming out be 45.30% of all the StateLives among Zing Health.


Thanks

1 ACCEPTED SOLUTION
v-luwang-msft
Community Support
Community Support

Hi @Anonymous ,

I tried to add it directly in the original code, but it failed, maxx is only used in this one dax can not be effective, in addition, because the follow-up to return the maximum total number of Status names, I suggest using the following Solutions.

If work on base table ,you could add a new column:

 

StateLive2 = 
CALCULATE (
    SUM ( 'Table'[StateLive] ),
    FILTER (
        ALL ( 'Table' ),
        'Table'[Controller] = EARLIER ( 'Table'[Controller] )
            && 'Table'[Status] = EARLIER ( 'Table'[Status] )
    )
)

 

vluwangmsft_0-1639534278943.png

 

And if work on a calculate table ,you could use the below dax:

 

test2 = SUMMARIZE('Table','Table'[Controller],'Table'[Status], "sumvalue", SUM('Table'[StateLive]))

 

 

vluwangmsft_1-1639534350763.png

 

 

Best Regards

Lucien

View solution in original post

7 REPLIES 7
v-luwang-msft
Community Support
Community Support

Hi @Anonymous ,

I tried to add it directly in the original code, but it failed, maxx is only used in this one dax can not be effective, in addition, because the follow-up to return the maximum total number of Status names, I suggest using the following Solutions.

If work on base table ,you could add a new column:

 

StateLive2 = 
CALCULATE (
    SUM ( 'Table'[StateLive] ),
    FILTER (
        ALL ( 'Table' ),
        'Table'[Controller] = EARLIER ( 'Table'[Controller] )
            && 'Table'[Status] = EARLIER ( 'Table'[Status] )
    )
)

 

vluwangmsft_0-1639534278943.png

 

And if work on a calculate table ,you could use the below dax:

 

test2 = SUMMARIZE('Table','Table'[Controller],'Table'[Status], "sumvalue", SUM('Table'[StateLive]))

 

 

vluwangmsft_1-1639534350763.png

 

 

Best Regards

Lucien

Anonymous
Not applicable

Thank you @v-luwang-msft 

v-luwang-msft
Community Support
Community Support

Hi @Anonymous ,

Test the below:

test = 
VAR maxevery =
    CALCULATE (
        MAX ( 'Table'[StateLive] ),
        FILTER ( ALL ( 'Table' ), 'Table'[Controller] = MAX ( 'Table'[Controller] ) )
    )
VAR maxstatus =
    CALCULATE (
        MAX ( 'Table'[Status] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[Controller] = MAX ( 'Table'[Controller] )
                && 'Table'[StateLive] = maxevery
        )
    )
VAR total_sum =
    SUM ( 'Table'[Statelive] )
RETURN
  maxstatus & " " &    FORMAT (DIVIDE ( maxevery, total_sum ), "0.00%" )

A little adjust to your base data:

vluwangmsft_0-1639473761082.png

 

Output Result:

vluwangmsft_1-1639473779248.png

 

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


Best Regards

Lucien

 

Anonymous
Not applicable

@v-luwang-msft This is almost there. There is just 1 more thing required. 

The data in the database is like this :

Ritindeep_0-1639524176671.png

So first step is to group it by Controller, Status and do sum of Statelives.
On the resulting view, the above code can work perfectly fine.

Is there a way to add this grouping also within this code? 

Thanks,


Anonymous
Not applicable

Thanks @Samarth_18 , 

The code works fine, but there is 1 issue. The requirement is not to capture "Unknown" but the any status which has maximum StateLives within that controller. 

In my above example, all 3 controllers had max Statelives for Unknown, but in reality, the code should automatically detect which status has max StateLives and then it just shows that status in winning percent.


Best, Ritin

Samarth_18
Community Champion
Community Champion

Hi @Anonymous ,

 

You can try below code:-

Win_per = 
VAR total_sum =
    SUM ( Winning_percenatge[Statelives] )
VAR unknown_statelive =
    CALCULATE (
        SUM ( Winning_percenatge[Statelives] ),
        Winning_percenatge[Status] = "Unknown"
    )
RETURN
    "Unknown " & FORMAT ( DIVIDE ( unknown_statelive, total_sum ), "0.00%" )

image.png

 

Thanks,

Samarth

 

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

Anonymous
Not applicable

@Samarth_18 
Below is another example of what I am trying to achieve:

Sample of data table I have: 

Ritindeep_0-1639423158136.png

The Output should be:

Ritindeep_1-1639423197399.png

That is, for each controller, I want to check the status which has maximum lives and then concatenate that status label with the percentage of its statelives. 

Below is an example of how to get the percentage value for each controller:

Percent calc for Controller = "Health Care Service Corporation"
(5518072) / (341426 + 888621 + 655404 + 5518073)

 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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