Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
bedata1
Frequent Visitor

Total Column in Bar Chart for multiple years

Hi Community, 

 

I created a bar chart with a total column. 

The goal is, to have just one total column that shows the summarization of all selected years. The Selection is a slicer.

 

I have the following DAX formula: 

 

Total_Sales_Chart =
VAR total_ = CALCULATE([Total_Sales], REMOVEFILTERS(Month_Name), REMOVEFILTERS('Date'[Year]))
VAR maxSelectedYear = CALCULATE(MAX('Date'[Year]), ALLSELECTED('Date'[Year]))
RETURN
IF(
    SELECTEDVALUE(Month_Name[Month_Name]) = "Total" && SELECTEDVALUE('Date'[Year]) = maxSelectedYear,
    total_,
    [Total_Sales]
)
 
It looks great and also the summarization is working fine. The only problem left is that it shows the total in every year but I want that the total is shown just at the last selected year:
bedata1_0-1722254875933.png

Do you have any idea how to reach this goal?

 

Thank you

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @bedata1 ,

You can update the formula of measure [Total_Sales_Chart] as below to get it:

Total_Sales_Chart =
VAR _selmonth =
    SELECTEDVALUE ( Month_Name[Month_Name] )
VAR _selyear =
    SELECTEDVALUE ( 'Date'[Year] )
VAR total_ =
    CALCULATE (
        [Total_Sales],
        REMOVEFILTERS ( Month_Name ),
        REMOVEFILTERS ( 'Date'[Year] )
    )
VAR maxSelectedYear =
    CALCULATE ( MAX ( 'Date'[Year] ), ALL ( 'Date' ) )
RETURN
    IF (
        _selmonth = "Total",
        IF ( _selyear = maxSelectedYear, total_, BLANK () ),
        [Total_Sales]
    )

If the above ones can't help you figure out, please provide some raw data in your tables(exclude sensitive data) with Text format and your expected result with backend logic and special examples. It would be helpful to find out the solution. You can refer the following link to share the required info:

How to provide sample data in the Power BI Forum

 

And It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi @bedata1 ,

You can update the formula of measure [Total_Sales_Chart] as below to get it:

Total_Sales_Chart =
VAR _selmonth =
    SELECTEDVALUE ( Month_Name[Month_Name] )
VAR _selyear =
    SELECTEDVALUE ( 'Date'[Year] )
VAR total_ =
    CALCULATE (
        [Total_Sales],
        REMOVEFILTERS ( Month_Name ),
        REMOVEFILTERS ( 'Date'[Year] )
    )
VAR maxSelectedYear =
    CALCULATE ( MAX ( 'Date'[Year] ), ALL ( 'Date' ) )
RETURN
    IF (
        _selmonth = "Total",
        IF ( _selyear = maxSelectedYear, total_, BLANK () ),
        [Total_Sales]
    )

If the above ones can't help you figure out, please provide some raw data in your tables(exclude sensitive data) with Text format and your expected result with backend logic and special examples. It would be helpful to find out the solution. You can refer the following link to share the required info:

How to provide sample data in the Power BI Forum

 

And It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.