Forum Discussion
Function DATESINPERIOD doesn't work properly
- 1 year ago
Hi antarizana
I really sorry for the confusion here is the refined DAX that will help you to resolve our issue.
If you still need facing anu issues please share the sample data so that i can help you address your requiement.
Updated DAX
Rolling12Months =
VAR __SelectedDate = MAX('Date'[Date])
VAR __StartDate = EDATE(__SelectedDate, -11) // includes 12 months
RETURN
CALCULATE(
SUM(YourTable[Amount]),
DATESBETWEEN(
'Date'[Date],
__StartDate,
__SelectedDate
)
)
If the above information is helpful, please give us Kudos and mark the response as Accepted as solution.
Best Regards,
Community Support Team _ C Srikanth.
Hi antarizana
Hello and welcome to the Microsoft Fabric Community.
Please consider trying the following workarounds that may help resolve your issue.
1) This approach ensures that January is handled correctly without any calculation errors.
**************************************************************
MonthlyAmount =
IF (
MONTH(MAX('Kalendar'[Date])) = 1,
[Cumulative],
[Cumulative] - CALCULATE([Cumulative], PARALLELPERIOD('Kalendar'[Date], -1, MONTH))
)
**************************************************************
2) If you're working with multiple accounts or dimensions, using ALLEXCEPT ensures proper filtering and context control.
**************************************************************
Rolling12MonthSum =
CALCULATE(
SUM('Table'[MonthlyAmount]),
DATESINPERIOD('Kalendar'[Date], MAX('Kalendar'[Date]), -12, MONTH),
ALLEXCEPT('Table', 'Table'[Account])
)
**************************************************************
If the above information helps you, please give us a Kudos and marked the reply Accept as a Solution.
Thanks,
Cheri Srikanth