Forum Discussion
Difference between two measures
- 3 years ago
Hi, sara_pinto15
The two measures you provided are almost identical, except for the time period they cover. The SPLM measure calculates the values up to (Today - 1 day - 1 month), while the SPLY measure calculates the values up to (Today - 1 day - 1 year).
The difference between the two measures is in the DATEADD function used in the CALCULATE function. The DATEADD function is used to subtract a certain number of days, months, or years from a given date. In the SPLM measure, the DATEADD function subtracts one month from the current date, while in the SPLY measure, it subtracts one year from the current date.
Here is the modified SPLM measure that calculates the values up to (Today - 1 day - 1 month):
.SPLM = VAR LastValue = CALCULATE( LASTDATE('FAT_Values'[CALDAY]), ALL('FAT_Values') ) VAR LimitDate = DATEADD(TODAY(),-1,MONTH) RETURN CALCULATE( [.Values_MTD], FILTER( ALL('dCalendar'), 'dCalendar'[Date]<=LimitDate ) )And here is the modified SPLY measure that calculates the values up to (Today - 1 day - 1 year):
.SPLY = VAR LastValue = CALCULATE( LASTDATE('FAT_Values'[CALDAY]), ALL('FAT_Values') ) VAR LimitDate = DATEADD(TODAY(),-1,YEAR) RETURN CALCULATE( [.Values_MTD], FILTER( ALL('dCalendar'), 'dCalendar'[Date]<=LimitDate ) )Note that the DATEADD function subtracts one month or one year from the current date, and the TODAY function returns the current date.
Best Regards,
Community Support Team _Charlotte
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, sara_pinto15
The two measures you provided are almost identical, except for the time period they cover. The SPLM measure calculates the values up to (Today - 1 day - 1 month), while the SPLY measure calculates the values up to (Today - 1 day - 1 year).
The difference between the two measures is in the DATEADD function used in the CALCULATE function. The DATEADD function is used to subtract a certain number of days, months, or years from a given date. In the SPLM measure, the DATEADD function subtracts one month from the current date, while in the SPLY measure, it subtracts one year from the current date.
Here is the modified SPLM measure that calculates the values up to (Today - 1 day - 1 month):
.SPLM =
VAR LastValue =
CALCULATE(
LASTDATE('FAT_Values'[CALDAY]),
ALL('FAT_Values')
)
VAR LimitDate = DATEADD(TODAY(),-1,MONTH)
RETURN
CALCULATE(
[.Values_MTD],
FILTER(
ALL('dCalendar'),
'dCalendar'[Date]<=LimitDate
)
)
And here is the modified SPLY measure that calculates the values up to (Today - 1 day - 1 year):
.SPLY =
VAR LastValue =
CALCULATE(
LASTDATE('FAT_Values'[CALDAY]),
ALL('FAT_Values')
)
VAR LimitDate = DATEADD(TODAY(),-1,YEAR)
RETURN
CALCULATE(
[.Values_MTD],
FILTER(
ALL('dCalendar'),
'dCalendar'[Date]<=LimitDate
)
)
Note that the DATEADD function subtracts one month or one year from the current date, and the TODAY function returns the current date.
Best Regards,
Community Support Team _Charlotte
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.