Forum Discussion
Help: Select Dates for a Measure Dynamically
- 5 years ago
Are you using Calendar[Date] in the SAMEPERIODLASTYEAR function?
The contiguous selection error usually shows when you try to implement time intelligence functions (DATESYTD, SAMEPERIODLASTYEAR etc.) using the date field from your fact table (where there isn't always contiguous dates) instead of using the date field from your calendar table (where there ARE contiguous dates by definition).
Your measures should look something like this:
//Measure for current year value _invoiceSpend = SUM(Invoice_Spend[Invoice Spend]) //Measure for prior year value _invoiceSpendPY = CALCULATE( [_invoiceSpend], SAMEPERIODLASTYEAR(Calendar[Date]) )Using these measures with a BETWEEN slicer containing Calendar[Date] should do exactly what you want.
Pete
Hi mohammedismail ,
You could use a slicer with calendar[Date]. Change the slicer type to 'Between'.
Adjust your code so that the 'from' date is MIN(calendar[DATE]), and your 'to' date is MAX(calendar[Date]).
Pete
In fatc, using the date slicer like this, you don't even need the DATESBETWEEN function in your measure. Power BI will aggregate your [Invoice Spend] measure automatically as the end user changes the slicer dates.
Pete