Forum Discussion

SpikeSpiegel_3's avatar
SpikeSpiegel_3
Frequent Visitor
2 years ago
Solved

Add total bar to bars in clustered column chart

This is the clustered column chart I created and I want to add total bar for each month, so the status is (total, done, in progress, new) and each month has 4 bars for the 4 status. Is there any way to get it done ?

 

 

  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi SpikeSpiegel_3 ,

     

    According to your description, here are my steps you can follow as a solution.

    (1) This is my test data.  

    (2) We can create a calculated column.

    Month = FORMAT('Table'[date],"mmmm")

    (3) We can create a table.

    Table 2 = var a=SUMMARIZE('Table','Table'[status])
    var b={"Total"}
    var c=SUMMARIZE('Table','Table'[Month])
    return GENERATEALL(c,UNION(b,a))

    (4) We can create a measure.

    Measure = 
    var _a=CALCULATE(SUM('Table'[value]),FILTER(ALLSELECTED('Table'),'Table'[Month] in VALUES('Table 2'[Month]) && 'Table'[status] in VALUES('Table 2'[Status])))
    var _b=CALCULATE(SUM('Table'[value]),FILTER(ALLSELECTED('Table'),'Table'[Month] in VALUES('Table 2'[Month]) ))
    return IF(SELECTEDVALUE('Table 2'[Status])="Total",_b,_a)

    (5) Then the result is as follows.

    Best Regards,

    Neeko Tang

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

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi SpikeSpiegel_3 ,

     

    According to your description, here are my steps you can follow as a solution.

    (1) This is my test data.  

    (2) We can create a calculated column.

    Month = FORMAT('Table'[date],"mmmm")

    (3) We can create a table.

    Table 2 = var a=SUMMARIZE('Table','Table'[status])
    var b={"Total"}
    var c=SUMMARIZE('Table','Table'[Month])
    return GENERATEALL(c,UNION(b,a))

    (4) We can create a measure.

    Measure = 
    var _a=CALCULATE(SUM('Table'[value]),FILTER(ALLSELECTED('Table'),'Table'[Month] in VALUES('Table 2'[Month]) && 'Table'[status] in VALUES('Table 2'[Status])))
    var _b=CALCULATE(SUM('Table'[value]),FILTER(ALLSELECTED('Table'),'Table'[Month] in VALUES('Table 2'[Month]) ))
    return IF(SELECTEDVALUE('Table 2'[Status])="Total",_b,_a)

    (5) Then the result is as follows.

    Best Regards,

    Neeko Tang

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