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! Request now

Reply
Anonymous
Not applicable

Create Filter on Column for visual showing 5 month window including last, current, and 3 next months

I have reports with a data set from Microsoft Project Web App. One of these reports has 3 visuals of Resource Availability. I'm trying to create a filter which allows me to show last month's availability, current month, and the next 3 months. Similiar to if you created a built in relative date filter that could overlap using an 'Or'. I've been accomplishing this monthly by going in and swapping checkboxes, but I'm trying to rid myself of that task and just can't solve the expression to do it.

I'm currently tapped into the Tables 'Resource Name' and 'TimeSet' to show the data. 

What I think would work is if I could find the way the native filters are expressed and throw them into an 'Or' statement but have been unable to accomplish that utilizing TODAY().

patkelly1008_0-1672260802606.png

The visuals I'm referring to with details redacted.



1 ACCEPTED SOLUTION
Anonymous
Not applicable

So the slicers are what I had already tried and I couldn't add slicers that went both backward and forward. I ended up figuring out a resut and wrote the following, which worked after drawing the right model relationships:

Calendar =
ADDCOLUMNS(
            CALENDAR(
                    Date(2022,1,1),
                    Date(2022,12,31)
                    ),
            "YYYY-MM", 
                      Format([Date],"YYYY-MM"),
            "Month_filter",
                        VAR CurrentDate = TODAY()
                        VAR ThisMonth = Format(EOMONTH(CurrentDate,
                                               0),"YYYY-MM")
                        VAR LastMonth = Format(EOMONTH(CurrentDate, 
                                               -1),"YYYY-MM")
                        VAR NextMonth1 = Format(EOMONTH(CurrentDate, 
                                               1),"YYYY-MM")
                        VAR NextMonth2 = Format(EOMONTH(CurrentDate, 
                                               2),"YYYY-MM")
                        VAR NextMonth3 = Format(EOMONTH(CurrentDate, 
                                               3),"YYYY-MM")
                        VAR month_list = COMBINEVALUES(",",
                                                        ThisMonth,
                                                        LastMonth,
                                                        NextMonth1,
                                                        NextMonth2,
                                                        NextMonth3
                                                      )
                                                      
                        Return
                        if(
                            CONTAINSSTRING(month_list,
                                           Format([Date],"YYYY-MM")),
                            TRUE(),
                            FALSE())
            )

 

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

I dont think this will be dynamic - can anyone advice?

Anonymous
Not applicable

Hi @Anonymous 

You can create a date table first, then add a column to judge if it is the current month or other types, pleaserefer to the following links:

Slicer to get Current Year/Pervious Year and Curre... - Microsoft Power BI Community

Power BI: Creating a Date Table using DAX (linkedin.com)

Use a relative date slicer or filter in Power BI - Power BI | Microsoft Learn

 

Best Regards!

Yolo Zhu

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

Anonymous
Not applicable

So the slicers are what I had already tried and I couldn't add slicers that went both backward and forward. I ended up figuring out a resut and wrote the following, which worked after drawing the right model relationships:

Calendar =
ADDCOLUMNS(
            CALENDAR(
                    Date(2022,1,1),
                    Date(2022,12,31)
                    ),
            "YYYY-MM", 
                      Format([Date],"YYYY-MM"),
            "Month_filter",
                        VAR CurrentDate = TODAY()
                        VAR ThisMonth = Format(EOMONTH(CurrentDate,
                                               0),"YYYY-MM")
                        VAR LastMonth = Format(EOMONTH(CurrentDate, 
                                               -1),"YYYY-MM")
                        VAR NextMonth1 = Format(EOMONTH(CurrentDate, 
                                               1),"YYYY-MM")
                        VAR NextMonth2 = Format(EOMONTH(CurrentDate, 
                                               2),"YYYY-MM")
                        VAR NextMonth3 = Format(EOMONTH(CurrentDate, 
                                               3),"YYYY-MM")
                        VAR month_list = COMBINEVALUES(",",
                                                        ThisMonth,
                                                        LastMonth,
                                                        NextMonth1,
                                                        NextMonth2,
                                                        NextMonth3
                                                      )
                                                      
                        Return
                        if(
                            CONTAINSSTRING(month_list,
                                           Format([Date],"YYYY-MM")),
                            TRUE(),
                            FALSE())
            )

 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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
Top Kudoed Authors