Forum Discussion
Dynamic Dates for 13-Month Trend
- 1 year ago
Hi,
I have solved a similar question in the attached PBI file.
abd8,
The calculated table you created in step 5 is unable to recognize user-specified filters in Report view (e.g., slicers). See link below for a dynamic solution:
https://www.sqlbi.com/articles/show-previous-6-months-of-data-from-single-slicer-selection/
- abd81 year agoRegular Visitor
This is very helpful. However, when I try to implement that code, I'm getting this error:
USERELATIONSHIP function can only use the two columns references participating in relationship.
I did tweak it slightly for my use case, so that may be what's causing it:
13_Month_Trend =VAR NumOfMonths = -13VAR ReferenceDate = 'Calendar'[SelectedMonth]VAR PreviousDates =DATESINPERIOD ('Previous Date'[Date],ReferenceDate,NumOfMonths,MONTH)VAR Result =CALCULATE (SELECTEDMEASURE (),REMOVEFILTERS ( 'Calendar' ),KEEPFILTERS ( PreviousDates ),USERELATIONSHIP ( 'Previous Date'[Date], 'Calendar'[SelectedMonthColumn] ))RETURN Result- DataInsights1 year ago
Super User
abd8,
Verify the columns in the relationship between 'Previous Date' and 'Calendar'. The columns in the relationship should be used in the USERELATIONSHIP function.
- abd81 year agoRegular Visitor
Ok, I set up the relationship and that formala is now working. How do I now set up my slicer and x-axis to ensure a proper 13-month lookback on the x-axis based on the slicer selection?