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 September 15. Request your voucher.

Reply
Zuz
Frequent Visitor

Chart with Total Show Hide columns from the previous year that have no importance in the CY

Hi all,

I have a table of consumption values from last year and this year. There are added weekly new values only from the current year. I want to create a bar chart but hide columns from the previous year that have no importance in the current year. 

chart.PNG

I have created a measure: (total should sum values for columns in chart)

Total Amount AY = 
VAR _Total = 
    CALCULATE([Total kWh],ALL(Months_with_Total))
RETURN
SWITCH(
    SELECTEDVALUE('Months_with_Total'[Month Name]),
                    "Total", _Total,
                    [Total kWh])

 

I have created a table with the month "Total":

Months_with_Total = 
DISTINCT(
    UNION(
        SELECTCOLUMNS('Calendar',
                        "Month Name", 'Calendar'[Month],
                        "Month Number", 'Calendar'[MonthNum]
        ),
        DATATABLE(
            "Month Name", STRING, "Month Number", INTEGER, {{"Total", 13}}
        )
    )
)

 

My table relationships:

relationships.PNG

 

I tried adding some filters to my measure but it didn't work.  What I'm doing wrong? 

Thank you for your advice. 

 

 

1 ACCEPTED SOLUTION
Zuz
Frequent Visitor

Solved by me 😊

 

 

Total by Month = 
VAR _Total = 
    CALCULATE([Total kWh],ALL(Months_with_Total))
RETURN
SWITCH(
    SELECTEDVALUE('Months_with_Total'[Month Name]),
                    "Total", _Total,
                    [Total kWh])

 

This measure works perfectly.  There was a problem with another filter.  I set relationships to "None" for the second slicer. Created slicer "Months" from the Calendar table and assign it to this chart. All works correctly.  

 

View solution in original post

2 REPLIES 2
Zuz
Frequent Visitor

Solved by me 😊

 

 

Total by Month = 
VAR _Total = 
    CALCULATE([Total kWh],ALL(Months_with_Total))
RETURN
SWITCH(
    SELECTEDVALUE('Months_with_Total'[Month Name]),
                    "Total", _Total,
                    [Total kWh])

 

This measure works perfectly.  There was a problem with another filter.  I set relationships to "None" for the second slicer. Created slicer "Months" from the Calendar table and assign it to this chart. All works correctly.  

 

Zuz
Frequent Visitor

I have modified my measure to this:

Total by Month = 
VAR _Total = 
    CALCULATE([Total kWh],FILTER(Months_with_Total,Months_with_Total[Month Number] <= MONTH(TODAY())-1))

RETURN
    SWITCH(SELECTEDVALUE(Months_with_Total[Month Number]), 13,"", _Total)

Now the matrix table shows only relevant months. 

total.PNG

I don't know to create VAR or measure "the Total". The total should be the same value as in my Matrix table. I tried a lot of calculations but without success.  Thank you for your advice. 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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