Forum Discussion
CALCULATE function does not filter data
- 4 years ago
Hi SaiSpandana2811 ,
I think you can try to use the DATESINPERIOD function to quickly solve for the sum over the past period of dates. Refer to the following formula:
M_ = CALCULATE ( SUM ( 'Table'[Value] ), DATESINPERIOD ( 'Table'[Date], MAX ( 'Table'[Date] ), -12, MONTH ) )Or create a date column and dynamically filter a date to find the sum over time.
M_1 = CALCULATE ( SUM ( 'Table'[Value] ), DATESINPERIOD ( 'Table'[Date], SELECTEDVALUE ( Tab_data[Date] ), -12, MONTH ) )Also you can read related blog for more details:
5 ways to calculate last 12 months in DAX for Power BI - BI Gorilla
Solved: How to calculate last 12 months - Microsoft Power BI Community
If the problem is still not resolved, please provide detailed error information and let me know immediately. Looking forward to your reply.
Best Regards,
Henry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
You may be overcomplicating things a bit. Read about the EDATE() function. Also, your comparators are the wrong way round.
Instead of
pbi_inc[yymm] >=lm , pbi_inc[yymm] <=r12m
you should use
pbi_inc[yymm] <=lm , pbi_inc[yymm] >=r12m