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
emrei
Frequent Visitor

PowerBI Displaying % of Flagged Columns in a bar chart

Hi everyone, I have the following data set. For each category, In a bar chart I am trying to show what % of parts are risky or not. Similar to this example but in powerbi. I would also love to have a subcategory drill down. Does anyone have any recommendations

 

emrei_0-1686347593171.png

emrei_1-1686347942205.png

 

2 ACCEPTED SOLUTIONS
ryan_mayu
Super User
Super User

@emrei 

you can create a measure

Measure = CALCULATE(COUNTROWS('Table'),FILTER('Table','Table'[risk]="Y"))/COUNTROWS('Table')+0

and drag category and sub-catogory to x-axis

1.PNG

click drill down to display subcategory

2.PNG

pls see the attachment below

 





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

Proud to be a Super User!




View solution in original post

Ritaf1983
Super User
Super User

Hi @emrei 
You can manipulate your drill level calculations with Isfiltered function, so you an use this DAX code:

Risk% =
IF (
    ISFILTERED ( 'Table'[Subcat] ),
    CALCULATE (
        DISTINCTCOUNT ( 'Table'[Part] ),
        FILTER ( 'Table', 'Table'[Risk] = "Y" )
    )
        / CALCULATE ( COUNTROWS ( 'Table' ), ALLEXCEPT ( 'Table', 'Table'[Subcat] ) ),
    IF (
        ISFILTERED ( 'Table'[Category] ),
        CALCULATE (
            DISTINCTCOUNT ( 'Table'[Part] ),
            FILTER ( 'Table', 'Table'[Risk] = "Y" )
        )
            / CALCULATE ( COUNTROWS ( 'Table' ), ALLEXCEPT ( 'Table', 'Table'[Category] ) )
    )
)+0

 If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly

View solution in original post

2 REPLIES 2
Ritaf1983
Super User
Super User

Hi @emrei 
You can manipulate your drill level calculations with Isfiltered function, so you an use this DAX code:

Risk% =
IF (
    ISFILTERED ( 'Table'[Subcat] ),
    CALCULATE (
        DISTINCTCOUNT ( 'Table'[Part] ),
        FILTER ( 'Table', 'Table'[Risk] = "Y" )
    )
        / CALCULATE ( COUNTROWS ( 'Table' ), ALLEXCEPT ( 'Table', 'Table'[Subcat] ) ),
    IF (
        ISFILTERED ( 'Table'[Category] ),
        CALCULATE (
            DISTINCTCOUNT ( 'Table'[Part] ),
            FILTER ( 'Table', 'Table'[Risk] = "Y" )
        )
            / CALCULATE ( COUNTROWS ( 'Table' ), ALLEXCEPT ( 'Table', 'Table'[Category] ) )
    )
)+0

 If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly

ryan_mayu
Super User
Super User

@emrei 

you can create a measure

Measure = CALCULATE(COUNTROWS('Table'),FILTER('Table','Table'[risk]="Y"))/COUNTROWS('Table')+0

and drag category and sub-catogory to x-axis

1.PNG

click drill down to display subcategory

2.PNG

pls see the attachment below

 





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

Proud to be a Super User!




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.