Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
ryanbott
Frequent Visitor

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)

ryanbott_0-1612915001193.png

 

ex. the settings on the visual for its axis

ryanbott_5-1612915448319.png

 

ex. some of the sample data. 

ryanbott_3-1612915378181.png

 

ex. a cropped part of the data model

ryanbott_4-1612915387508.png

 

 

1 ACCEPTED SOLUTION
v-lionel-msft
Community Support
Community Support

Hi @ryanbott ,

 

Please refer to the blog.

Display Last N Months & Selected Month using Single Date Dimension in Power BI 

v-lionel-msft_0-1613525868789.png

 

Best regards,
Lionel Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

4 REPLIES 4
v-lionel-msft
Community Support
Community Support

Hi @ryanbott ,

 

Please refer to the blog.

Display Last N Months & Selected Month using Single Date Dimension in Power BI 

v-lionel-msft_0-1613525868789.png

 

Best regards,
Lionel Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

ryanbott
Frequent Visitor

Hi @Ashish_Mathur , unfortunately, I only have Excel for Mac and I'm unable to inspect your Excel solution to see if I can apply it in PowerBI.

Hi,

Download my MS Excel file and do not open it.  Open PowerBI Desktop and go to File > Import > Power Query, Power Pivot and Power View.  This will import all my work from the Excel file to the PBI Deskto file.  Thereafter, you will still have to open my Excel workbook to see which columns have to be dragged to which visual.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Ashish_Mathur
Super User
Super User

Hi,

See if my solution here helps - Flex a Pivot Table to show data for x months ended a certain user defined month.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors