Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Bar Chart Totals

Hi

 

Is there a way of presenting a total and a quantity in a bar chart?

 

ie. I need 5 Badgers, I only have 4. My bar will show up to 4 in green and 1 in red. Total 5.

 

Thanks in advance.

 

Paul

  • Hi Anonymous ,

     

    We can create a new table that contains all fields and a Total field, and use a measure to meet your requirement.

     

    1. Create a new table, create a relationship between two tables.

     

    Table 2 = 
    UNION ( DISTINCT ( 'Table'[name] ), { "Total" } )

     

     

    2. Then we can create a measure,

     

    Measure = 
    VAR amount =
        SUM ( 'Table'[value] )
    RETURN
    IF (
            ISBLANK ( amount ),
            CALCULATE ( SUM ( 'Table'[value] ), ALL('Table') ),
            amount
        	)

     

    3. At last we can create a bar chart, put the Table 2’s name to Axis and put the measure to Values.

     

     

    If it doesn’t meet your requirement, could you please show the exact expected result based on the table that we have shared?

    BTW, pbix as attached.

     

    Best regards,

     

    Community Support Team _ zhenbw

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

2 Replies

  • v-zhenbw-msft's avatar
    v-zhenbw-msft
    Icon for Community Support rankCommunity Support

    Hi Anonymous ,

     

    We can create a new table that contains all fields and a Total field, and use a measure to meet your requirement.

     

    1. Create a new table, create a relationship between two tables.

     

    Table 2 = 
    UNION ( DISTINCT ( 'Table'[name] ), { "Total" } )

     

     

    2. Then we can create a measure,

     

    Measure = 
    VAR amount =
        SUM ( 'Table'[value] )
    RETURN
    IF (
            ISBLANK ( amount ),
            CALCULATE ( SUM ( 'Table'[value] ), ALL('Table') ),
            amount
        	)

     

    3. At last we can create a bar chart, put the Table 2’s name to Axis and put the measure to Values.

     

     

    If it doesn’t meet your requirement, could you please show the exact expected result based on the table that we have shared?

    BTW, pbix as attached.

     

    Best regards,

     

    Community Support Team _ zhenbw

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