The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.
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 |
---|---|
58 | |
56 | |
55 | |
50 | |
32 |
User | Count |
---|---|
171 | |
87 | |
70 | |
46 | |
45 |