Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.
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.
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:
I tried adding some filters to my measure but it didn't work. What I'm doing wrong?
Thank you for your advice.
Solved! Go to Solution.
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.
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.
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.
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.
User | Count |
---|---|
98 | |
76 | |
74 | |
49 | |
26 |