I have a date slicer Based on a date selection I'd like to see Sales for this year (TY) and last year (LY)
If current month is selected on a slicer then it should show MTD sales TY and MTD LY If previous months are selected then it should give me full month TY and LY actual sales
- Is there a way I can code DAX so that users can interact with slicers and see respective sales?
- Is there a way to save current month (February 2025) as selected by default in date slicer?
I tried with SAMEPERIODLASTYEAR but it gives me full month for Feb'24 - I just need MTD for current month. Current month = my last sales date in my fact table (Feb'13 2025 in this case)
I have a date slicer Based on a date selection I'd like to see Sales for this year (TY) and last year (LY)
If current month is selected on a slicer then it should show MTD sales TY and MTD LY If previous months are selected then it should give me full month TY and LY actual sales
- Is there a way I can code DAX so that users can interact with slicers and see respective sales?
- Is there a way to save current month (February 2025) as selected by default in date slicer?
I tried with SAMEPERIODLASTYEAR but it gives me full month for Feb'24 - I just need MTD for current month. Current month = my last sales date in my fact table (Feb'13 2025 in this case)
Share Improve this question asked Feb 15 at 3:45 B TB T 291 silver badge5 bronze badges 1- could you pls provide some sample data? do you have a date table? – Ryan Commented Feb 17 at 0:22
1 Answer
Reset to default 0Try capturing the max date and then using that within an outer calculate:
Your Measure =
var maxD = MAX(YourFactTable[Date])
var isCurMonth = (EOMONTH(MAX(YourDateTable[Date]), 0) = EOMONTH(TODAY(), 0))
var fullMonth = CALCULATE([Your TY Measure], DATEADD(YourDateTable[FMStartDate], -1, YEAR))
var partialMonth =
CALCULATE(
CALCULATE([Your TY Measure], DATEADD(YourDateTable[FMStartDate], -1, YEAR)),
YourDateTable[Date] <= maxD
)
var result = IF( isCurMonth, partialMonth, fullMonth)
return result