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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
vshinto
New Member

How to Display Selected Month Plus Previous Two Months Dynamically in Power BI Visuals?

Hello everyone,

I have a Power BI report with a date slicer based on a Calendar table. When a user selects a month (e.g., December 2025), I want my visuals (tables and charts) to show data for the selected month plus the two previous months. For example:

  • If December 2025 is selected → show October, November, and December 2025.
  • If November 2025 is selected → show September, October, and November 2025.

    Thank you.
1 ACCEPTED SOLUTION
Peter_23
Post Patron
Post Patron

Hi, @vshinto , you have try with a disconnected table for display the dimensiones previous values from slicer.

 

View solution in original post

4 REPLIES 4
Ashish_Mathur
Super User
Super User

Hi,

I have solved a similar question in the attached file.

Hope this helps.


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

Hi, @vshinto , you have try with a disconnected table for display the dimensiones previous values from slicer.

 

Hello i make something similar this to solve my problem.

Thank you.

Zanqueta
Solution Sage
Solution Sage

Hi @vshinto 

 

o achieve this dynamic behaviour in Power BI, you need a DAX measure or filter logic that reacts to the selected month and includes the two previous months. Here’s the recommended approach:

Solution Overview

  1. Use a Calendar table with a continuous date column and a Month-Year column.
  2. Create a measure or filter that checks if a date falls within the selected month and the two preceding months.

Step 1: Ensure Calendar Table

Your Calendar table should have:
  • Date column (continuous)
  • YearMonth column (e.g., 2025-12)
  • A relationship to your fact table.

Step 2: Create a DAX Measure for Filtering

You can use DATESINPERIOD or DATEADD inside CALCULATE:
 
 
SelectedAndPreviousTwoMonths =
VAR LastVisibleDate =
    MAX ( 'Calendar'[Date] )  // Última data visível no contexto do slicer
RETURN
CALCULATE (
    [Total Sales],
    DATESINPERIOD (
        'Calendar'[Date],
               LastVisibleDate,
        -3,
        MONTH
    )

 

Step 3: Apply to Visuals

  • Use this measure in your visuals.
  • If you need to filter rows (e.g., in a table), create a calculated column or use a visual-level filter with a similar logic:

 

ShowLast3Months =
VAR SelectedDate = MAX ( 'Calendar'[Date] )
RETURN
IF (
    'Calendar'[Date] >= EDATE ( SelectedDate, -2 )
        && 'Calendar'[Date] <= SelectedDate,
       1,
    0

  

Then filter visuals where ShowLast3Months = 1.
 
Official reference:
 

If this response was helpful in any way, I’d gladly accept a 👍much like the joy of seeing a DAX measure work first time without needing another FILTER.

Please mark it as the correct solution. It helps other community members find their way faster (and saves them from another endless loop 🌀.

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.