Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Total Sum last Bar Chart

Hi Team,

 

DAX -->

I have monthwise Bar chart in that need to add last Bar for Total sum.

 

 

 

 

Thanks,

Kv

  • Hi,

    I suggest having an additional axis table like below.

    I tried to create a sample pbix file like below.

    Please check the below picture and the attached pbix file.

    All measures are in the attached pbix file.

    I hope the below DAXs for creating an axis table and a measure provide ideas in order to create the solution for your data model.

     

     

    Axis table month = 
    UNION (
        SUMMARIZE ( 'Calendar', 'Calendar'[Month & Year], 'Calendar'[End of Month] ),
        ROW (
            "columnA", "Total",
            "columnB", MAXX ( 'Calendar', 'Calendar'[End of Month] + 1 )
        )
    )
    

     

     

     

    Value total measure: = 
    SWITCH (
        SELECTEDVALUE ( 'Axis table month'[Month & Year] ),
        "Total", SUM ( Data[Value] ),
        CALCULATE (
            SUM ( Data[Value] ),
            TREATAS (
                VALUES ( 'Axis table month'[Month & Year] ),
                'Calendar'[Month & Year]
            )
        )
    )

     

3 Replies

  • Hi,

    I suggest having an additional axis table like below.

    I tried to create a sample pbix file like below.

    Please check the below picture and the attached pbix file.

    All measures are in the attached pbix file.

    I hope the below DAXs for creating an axis table and a measure provide ideas in order to create the solution for your data model.

     

     

    Axis table month = 
    UNION (
        SUMMARIZE ( 'Calendar', 'Calendar'[Month & Year], 'Calendar'[End of Month] ),
        ROW (
            "columnA", "Total",
            "columnB", MAXX ( 'Calendar', 'Calendar'[End of Month] + 1 )
        )
    )
    

     

     

     

    Value total measure: = 
    SWITCH (
        SELECTEDVALUE ( 'Axis table month'[Month & Year] ),
        "Total", SUM ( Data[Value] ),
        CALCULATE (
            SUM ( Data[Value] ),
            TREATAS (
                VALUES ( 'Axis table month'[Month & Year] ),
                'Calendar'[Month & Year]
            )
        )
    )

     

  • Arul's avatar
    Arul
    Icon for Super User rankSuper User

    Anonymous ,

    you can also try to create a table with the below code and use it in bar chart,

    New Bar Table = 
    VAR _total= SUMMARIZECOLUMNS('Table'[Month],"1",SUM('Table'[Value]))
    VAR _columns= SELECTCOLUMNS(_total,"Month","Total","Value",[1])
    return
    UNION('Table',_columns)

    Thanks,

    Arul

     

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous,

    Did the above suggestions help with your scenario? if that is the case, you can consider Kudo or accept the helpful suggestions to help others who faced similar requirements.

    If these also don't help, please share more detailed information to help us clarify your scenario to test.

    How to Get Your Question Answered Quickly 

    Regards,

    Xiaoxin Sheng