Forum Discussion
DAX Formula
Hi jaineshpoojara - The issue you're facing with DAX functions such as DATESMTD and SAMEPERIODLASTYEAR returning values beyond the current date likely stems from the way these functions are interacting with your date table.
Dates =
ADDCOLUMNS (
CALENDAR (DATE(2023,1,1), TODAY()),
"Year", YEAR([Date]),
"Month", MONTH([Date]),
"Day", DAY([Date]),
"MonthName", FORMAT([Date], "MMMM"),
"Quarter", "Q" & QUARTER([Date]),
"YearMonth", YEAR([Date]) * 100 + MONTH([Date])
)
-- Mark as Date Table
Model.AddCalculatedTable("Dates", Dates)
For current date:
SalesSPLY =
CALCULATE (
[SalesMTDAdjusted],
SAMEPERIODLASTYEAR(DATESBETWEEN('Dates'[Date], STARTOFMONTH(TODAY()), TODAY()))
)
Add a date slicer to the report to dynamically adjust the date range and verify that the measures behave correctly with the slicer set to <= TODAY()
Did I answer your question? Mark my post as a solution! Appreciate your Kudos !!