Forum Discussion

ryanbott's avatar
ryanbott
Frequent Visitor
5 years ago
Solved

Dynamic Filtering of X-Axis

Hey there,

 

I'm looking to dynamically filter my visual with two slicers. One slicer is tied to an unrelated Date table to get access to all of the Month Year Date values in the data. The other slicer is tied to a table to pick between 1M, 3M, 6M, and 1Y periods. The effect I'd like to see is, for example, select June 2020 and 6M and then display the trailing 6 month period behind June 2020. I've been trying a handful of different things, and the closest was probably a new Calculated Table, but that won't support a Dynamic approach.

 

I had tried to create a measure that I would use on the y-axis, but it didn't seem to work out and I'm not exactly sure why.

 

MemberJoinedInTerm = 
VAR range = SELECTEDVALUE(MemberJoinedTimeChoice[TimeChoice])
VAR rangeMonth = SWITCH(range,
    "1M",
    -1,
    "3M",
    -3,
    "6M",
    -6,
    "1Y",
    -12
)
var startDateYear = YEAR(SELECTEDVALUE(Dates[Date]))
var startDate = DATE(startDateYear, 1 , 1)
var endDate = EOMONTH(EDATE(startDate, rangeMonth) ,0)
RETURN
CALCULATE(SUM(monthTable[New Members]), DATESINPERIOD(monthTable[Date].[Date], startDate, rangeMonth, MONTH))

 

ex. the visual that needs dynamic filtering & the two slicers that should provide the filtering inputs (start date & date period)

 

ex. the settings on the visual for its axis

 

ex. some of the sample data. 

 

ex. a cropped part of the data model

 

 

4 Replies