I having some trouble with PowerBI
I have a date dimension with an “End of Month” column and a fact table that contains records for each end of the month.
I would like to display the following in a single graph:
On the X-axis: the “End of Month” for the last 12 months, based on the selected month filter.
On the Y-axis: the cumulative total for each month, calculated over the previous 12 months.
For example, if I select June 2024, the graph will display months from July 2023 to June 2024 on the X-axis, and for June 2024, the cumulative total will represent the sum from July 2023 to June 2024. Additionally, for May 2024, it will show the cumulative total from June 2023 to May 2024, for April 2024 the cumulative total from May 2023 to April 2024, and so on, back to July 2023.
I created the following measures:
_NumberOfDepartures =
CALCULATE(
COUNTROWS(Fact_Termination),
Fact_Termination[EmployeeClass] = "Employee",
Fact_Termination[PermanentTemporary] = "Permanent"
)
Cumul12months = CALCULATE(
[_NumberOfDepartures],
DATESINPERIOD(
'Dim_Date'[End of Month],
MAX('Dim_Date'[End of Month]),
-12,
MONTH
),
REMOVEFILTERS('Dim_Date')
)
This solution currently works only if I manually select each month one by one in the slicer. However, I need it to be dynamic: when I select a single month, it should automatically calculate the rolling 12-month cumulative total for that month, and for each of the previous 12 months.
When I select only june 2024When I select manually all the 12months
I also tried another approach by creating a cumulative table in Power BI using the SUMMARIZE function. However, I ran into issues because I need to apply additional filters on other fields and perform calculations involving different tables. This is why I need the solution to be dynamic.
Can you help me with this, please?
Power BI simply will not return any other rows that have been selected in a slicer of the same table.
Try using your fact table Date field for the X-axis, instead of your Dim_Date
table (which I assume is what you are using for your slicer).