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
Stefaan-4365
New Member

Bar chart with true/false ratio

Hi

 

I have a table with three true/false columns, let’s call them isTested, isDeployed and isAccepted. From these columns I need to create a bar chart that shows each of these columns in two colors representing the true/false ratio. This proves to be a much more challenging than I expected, and any help would be greatly appreciated!

Thank you
Stefaan

3 REPLIES 3
v-lid-msft
Community Support
Community Support

Hi @Stefaan-4365 ,

 

How about the result after you follow the suggestions mentioned in my original post?Could you please provide more details about it If it doesn't meet your requirement?


Best regards,

Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
v-lid-msft
Community Support
Community Support

Hi @Stefaan-4365 ,

 

We can try to create a calculated table and a measure to meet your requirement:

 

calculated table:

 

Table 2 =
CROSSJOIN (
    DATATABLE (
        "Category", STRING,
        {
            { "isTested" },
            { "isDeployed" },
            { "isAccepted" }
        }
    ),
    { TRUE (), FALSE () }
)

 

 

measure:

 

Rate =
DIVIDE (
    SWITCH (
        SELECTEDVALUE ( 'Table 2'[Category], BLANK () ),
        "isTested", CALCULATE (
            COUNTROWS ( 'Table' ),
            'Table'[isTested] IN DISTINCT ( 'Table 2'[Value] )
        ),
        "isDeployed", CALCULATE (
            COUNTROWS ( 'Table' ),
            'Table'[isDeployed] IN DISTINCT ( 'Table 2'[Value] )
        ),
        "isAccepted", CALCULATE (
            COUNTROWS ( 'Table' ),
            'Table'[isAccepted] IN DISTINCT ( 'Table 2'[Value] )
        ),
        COUNTROWS ( 'Table' )
    ),
    COUNTROWS ( 'Table' ),
    0
)

 

 

10.jpg

 


If it doesn't meet your requirement, Could you please show the exact expected result based on the tables that we have shared?


By the way, PBIX file as attached.


Best regards,

 

Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
amitchandak
Super User
Super User

@Stefaan-4365 , Create a common dimension with the values true and false. Join them with all three columns. One will active and two will be inactive. Use userelation to make others active

 

How to use userelation : https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-tr...

 

Create a color column like this

Color Date = if(FIRSTNONBLANK(Table[Value],"true") ="true","green","red")

In coditnal fomatting use it after choosing the "Field"

refer

https://radacad.com/dax-and-conditional-formatting-better-together-find-the-biggest-and-smallest-num...

https://docs.microsoft.com/en-us/power-bi/desktop-conditional-table-formatting#color-by-color-values

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.