Forum Discussion
boby
9 years agoRegular Visitor
Compare sameperiodlastyear, from date to date
Hi all, eg : total amount = CALCULATE(sum(TABLE1[amount]); LASTDATE(TABLE1[Date])) = 23 Total amount sameperiodlastyear = CALCULATE([total amount ]; SAMEPERIODLASTYEAR(TABLE1[Date])) = 31 ...
- 9 years ago
Maybe exist a short version but i'll go to a meeting and don't have time to optimize
MTD = CALCULATE ( SUM ( Table1[Amount] ), FILTER ( DATESMTD ( Calendario[Date] ), Calendario[Date] <= TODAY () ) )M2 MTD LY = CALCULATE ( [MTD], FILTER ( DATEADD ( Calendario[Date], -1; YEAR ), Calendario[Date] <= DATE ( YEAR ( TODAY () ) - 1, MONTH ( TODAY () ), DAY ( TODAY () ) ) ) )
Vvelarde
Community Champion
9 years ago
Maybe exist a short version but i'll go to a meeting and don't have time to optimize
MTD =
CALCULATE (
SUM ( Table1[Amount] ),
FILTER ( DATESMTD ( Calendario[Date] ), Calendario[Date] <= TODAY () )
)M2 MTD LY =
CALCULATE (
[MTD],
FILTER (
DATEADD ( Calendario[Date], -1; YEAR ),
Calendario[Date]
<= DATE ( YEAR ( TODAY () ) - 1, MONTH ( TODAY () ), DAY ( TODAY () ) )
)
)acrmorris
9 years agoFrequent Visitor
Vvelarde, there may be a shorter solution, but this worked for me first time and because of the format means I can understand what is happening in the formula. Maybe I will take a look at shortening it myself when I have a bit more experience with Power BI.
Thanks for the post