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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
fionabee
Helper I
Helper I

Calculating a percentage within a distinct count

I'm currently using the following measure in a visual:

CALCULATE(COUNT(Table1[Status]),Table1[Status]="Accepted")/[Number]
 
In this measure "Number" was originally a count of all case numbers so the % would reflect correctly but I need "number" to reflect a distinct count so the above is now not calulating the percentage correctly as in this example below: 

CaseSub TypeOutcome
Case 1Sub 1Accepted
Case 1Sub 2Accepted
Case 2Sub 1Rejected
Case 2Sub 2Rejected
Case 3Sub 1Rejected
Case 3Sub 2Rejected
Case 3Sub 3Rejected

 

it would be counting 2 accepted statuses out of 3 cases so would display 67% where I want it to reflect that 33% of the 3 cases have an accepted status. Please could someone help me to include the distinct count element in the above measure?

1 ACCEPTED SOLUTION
DataNinja777
Super User
Super User

Hi @fionabee ,

 

To calculate the percentage of distinct cases that have at least one "Accepted" status, you need to shift from counting rows to identifying unique case IDs that meet your condition. Using a filtered table with CALCULATETABLE allows you to isolate the distinct case values where at least one row has a status of "Accepted." Then you divide that count by the total number of distinct cases to get the correct percentage.

Accepted Case % =
VAR AcceptedCases =
    CALCULATETABLE(
        VALUES(Table1[Case]),
        Table1[Status] = "Accepted"
    )
RETURN
DIVIDE(
    COUNTROWS(AcceptedCases),
    CALCULATE(DISTINCTCOUNT(Table1[Case]))
)

In this approach, AcceptedCases creates a virtual table of unique Case values where the status is "Accepted". COUNTROWS(AcceptedCases) gives the number of such cases, and the denominator uses CALCULATE(DISTINCTCOUNT(...)) to get the total number of distinct cases. This ensures that each case is only counted once, and only if it includes an accepted status. For your example, it returns 1 accepted case out of 3, or 33%.

 

Best regards,

View solution in original post

6 REPLIES 6
v-karpurapud
Community Support
Community Support

Hi @fionabee 

I hope this information is helpful. Please let me know if you have any further questions or if you'd like to discuss this further. If this answers your question, please Accept it as a solution and give it a 'Kudos' so others can find it easily.

Thank you.

v-karpurapud
Community Support
Community Support

Hi @fionabee 

I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If my response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.

Thank you.

v-karpurapud
Community Support
Community Support

Hi @fionabee 

May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.

Thank you.

v-karpurapud
Community Support
Community Support

Hi @fionabee 

 

Welcome to the Microsoft Fabric Forum. Also, thank you @DataNinja777 for the helpful response.

To calculate the percentage of distinct cases where Status is blank , you can simply adapt the previous measure by checking for blank values in the Status column.

DAX

Outstanding Case % :=

VAR OutstandingCases =

    CALCULATETABLE(

        VALUES(Table1[Case]),

        ISBLANK(Table1[Status])

    )

RETURN

DIVIDE(

    COUNTROWS(OutstandingCases),

    CALCULATE(DISTINCTCOUNT(Table1[Case]))

)


If this 
information helps resolve your issue, kindly consider marking this response as the Accepted Solution, as it may assist other community members facing similar challenges.


Regards, 
Microsoft Community Support.

DataNinja777
Super User
Super User

Hi @fionabee ,

 

To calculate the percentage of distinct cases that have at least one "Accepted" status, you need to shift from counting rows to identifying unique case IDs that meet your condition. Using a filtered table with CALCULATETABLE allows you to isolate the distinct case values where at least one row has a status of "Accepted." Then you divide that count by the total number of distinct cases to get the correct percentage.

Accepted Case % =
VAR AcceptedCases =
    CALCULATETABLE(
        VALUES(Table1[Case]),
        Table1[Status] = "Accepted"
    )
RETURN
DIVIDE(
    COUNTROWS(AcceptedCases),
    CALCULATE(DISTINCTCOUNT(Table1[Case]))
)

In this approach, AcceptedCases creates a virtual table of unique Case values where the status is "Accepted". COUNTROWS(AcceptedCases) gives the number of such cases, and the denominator uses CALCULATE(DISTINCTCOUNT(...)) to get the total number of distinct cases. This ensures that each case is only counted once, and only if it includes an accepted status. For your example, it returns 1 accepted case out of 3, or 33%.

 

Best regards,

Hello, this seems to work perfectly! Final question, could you please show me how to write the same for when the status field is blank? So in my visual I can show a % of how many are outstanding?

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.