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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
murali5431
Helper III
Helper III

How to summarize based on success / failure

Hello,

 

I am working on a dataset that has entries as below.

 

My objective is to calcluate the % of successful entries / total number of entries.

Any entry is considered successful only if all rows corresponding to the Entry number show "Y". Even 1 "N" against an entry number makes it a failure. Please assist with a DAX measure to calculate the percentage.

 

For below example AA2, AA3 & AA5 are considered successful based on above logic and hence the result should be 3/5 - 60% 

Entry NumberSuccess / Failure
AA1Y
AA1N
AA2Y
AA3Y
AA3Y
AA4N
AA4Y
AA5Y
AA5Y

 

Thanks for the help!

6 REPLIES 6
harshnathani
Community Champion
Community Champion

Hi @murali5431 ,

 

You can try this as a measure.

 

Results =
VAR failuretable =
    SUMMARIZE (
        'Table',
        'Table'[Entry Number],
        "Failure", CALCULATE (
            MAX ( 'Table'[Success / Failure] ),
            'Table'[Success / Failure] = "N"
        )
    )
VAR finaltable =
    COUNTROWS (
        EXCEPT (
            failuretable,
            'Table'
        )
    )
VAR distinctrowsinmaintable =
    DISTINCTCOUNT ( 'Table'[Entry Number] )
RETURN
    DIVIDE (
        finaltable,
        distinctrowsinmaintable
    )

 

Pull the measure onto a card for your visualization.

 

 

Regards,
Harsh Nathani

Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)

Hi @harshnathani ,

 

Thanks for the response!

 

My table actually has around 25 columns of data. I had shared two columns as these are the only two that matter for the calclualton. This is probably causing an error "Each table argument of 'EXCEPT' must have the same number of columns.".

 

Could you advise a workaround for this?

 

Thanks,

Murali

Hi @murali5431 ,

 

 

Try this

 

Results =
VAR failuretable =
    SUMMARIZE (
        'Table4',
        Table4[Entry Number],
        "Failure", CALCULATE (
            MAX ( Table4[Success / Failure] ),
            'Table4'[Success / Failure] = "N"
        )
    )
VAR fin =
    SUMMARIZE (
        Table4,
        Table4[Entry Number],
        Table4[Success / Failure]
    )
VAR finaltable =
    COUNTROWS (
        EXCEPT (
            failuretable,
            fin
        )
    )
VAR distinctrowsinmaintable =
    DISTINCTCOUNT ( 'Table4'[Entry Number] )
RETURN
    DIVIDE (
        finaltable,
        distinctrowsinmaintable
    )

 

 

Regards,

Harsh Nathani

Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)

Hi @murali5431 ,

 

Did the previous solution solve your issue.

 

If yes, please mark it as Solution for other users to benefit.

 

Regards,

HN

mahoneypat
Employee
Employee

Please try this expression that returns 60% for your example data.

 

Pct Successful =
VAR __summarytable =
    ADDCOLUMNS (
        VALUES ( Entry[Entry Number] ),
        "@N Count", CALCULATE ( COUNTROWS ( Entry ), Entry[Success / Failure] = "N" ) + 0
    )
RETURN
    DIVIDE (
        COUNTROWS ( FILTER ( __summarytable, [@N Count] = 0 ) ),
        COUNTROWS ( __summarytable )
    )

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


lbendlin
Super User
Super User

Divide the distinct count of all entries that have a No by the distinct count of all entries. Then subtract that from 1.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors