Forum Discussion
Incorrect Previous month value calculation
- 5 years ago
Hi Uzi2019 ,
Did you create a relationship between the two tables?
Best regards,
Lionel ChenIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- 5 years ago
Hi Syndicate_Admin ,
I create the following sample data, and then create a measure.
Ventas anteriores = var MonthEnd = CALCULATE( SUM('DataTable'[Sales]), DATEADD( 'Calendar'[Date], -1, MONTH ) ) var Month = CALCULATE( SUM('DataTable'[Sales]), FILTER( ALL('DataTable'), 'DataTable'[Date] <= EDATE( MAX('Calendar'[Date]), -1 ) &&'DataTable'[Date] >= EDATE( MIN('Calendar'[Date]), -1 ) ) ) var Result = IF( MAX('Calendar'[Date]) = EOMONTH( MAX('Calendar'[Date]), 0 ), MonthEnd, Month ) return ResultIf the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
WinnizIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi Syndicate_Admin ,
I create the following sample data, and then create a measure.
Ventas anteriores =
var MonthEnd =
CALCULATE(
SUM('DataTable'[Sales]),
DATEADD( 'Calendar'[Date], -1, MONTH )
)
var Month =
CALCULATE(
SUM('DataTable'[Sales]),
FILTER(
ALL('DataTable'),
'DataTable'[Date] <= EDATE( MAX('Calendar'[Date]), -1 )
&&'DataTable'[Date] >= EDATE( MIN('Calendar'[Date]), -1 )
)
)
var Result =
IF(
MAX('Calendar'[Date]) = EOMONTH( MAX('Calendar'[Date]), 0 ),
MonthEnd,
Month
)
return Result
If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.