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
WinterGarden
Helper IV
Helper IV

Showing month columns(Up coming months) in a matrix based on month selected from the slicer

Hi All,

I wanted to create a matrix, in which based on the month value selected in the slicer, i wanted to show 10 month columns on/after the selcted month.

this is how my current matix visual looks like:

WinterGarden_0-1756658291802.png

Slicer:
  Upcoming Date[MonthYear] (this is an independent table.. no relationship is created):

 
Upcoming Date =
ADDCOLUMNS (
    CALENDAR (DATE(2025,1,1), DATE(2035,12,31)),  -- adjust range
    "MonthYear", FORMAT([Date], "mmm-yy"),
    "FY",FORMAT([Date], "yyyy")
)

Matrix:

Row and values from : "All Items" table
Column from : CalendarTable[MonthYear]

CalendarTable =
ADDCOLUMNS (
    CALENDAR (DATE(2025,1,1), DATE(2035,12,31)),  -- adjust range
    "MonthYear", FORMAT([Date], "mmm yyyy"),
    "YearMonthNum", YEAR([Date]) * 12 + MONTH([Date]) - 1,
    "Year", YEAR([Date])
)

There is One to many relationship from CalendarTable[Date] to All Items[Delivery Date]


Task:
if i select Jan-25 in the silcer, then i wanted to show only 10 month columns on or after jan-25 in the matrix

now all the month columns are showing in the matrix:

WinterGarden_2-1756659598992.png

but i want to show only 10 month columns from jan 2025.. ie jan 2025, feb 2025,.....oct 2025
if Feb 2025 is selected then columns from Feb 2025 to nov 2025.

Fo that i have created a measure to filter that matrix. but it is not working:

 
ShowInMatrix =
VAR SelectedMonth =
    MINX(
        FILTER(
            ALL('Upcoming Date'),
            'Upcoming Date'[MonthYear] = SELECTEDVALUE('Upcoming Date'[MonthYear])
        ),
        'Upcoming Date'[Date]
    )

VAR CurrentMonth = MIN(CalendarTable[Date])

RETURN
IF (
    NOT ISBLANK(SelectedMonth) &&
    CurrentMonth >= SelectedMonth &&
    CurrentMonth < EDATE(SelectedMonth, 10),
    1,
    0
)



how can i filter columns in matrix? Could you please help?

 

1 ACCEPTED SOLUTION
danextian
Super User
Super User

Hi @WinterGarden 

Use a disconnected dates table  (without relationship to your fact or dates table) as using related one or from the same table as fact will only show rows based on slicer selection. Then create this measure:

 

Disconnected Total Revenue = 
VAR _SelectedPeriod =
    MIN ( DisconnectedDate[Date] )
VAR _P10 =
    EOMONTH ( _SelectedPeriod, 9 )
RETURN
    CALCULATE (
        [Total Revenue],
        KEEPFILTERS ( Dates[Date] >= _SelectedPeriod && Dates[Date] <= _P10 )
    )

danextian_1-1756702970402.gif

Please see the attached pbix.

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

13 REPLIES 13
danextian
Super User
Super User

Hi @WinterGarden 

Use a disconnected dates table  (without relationship to your fact or dates table) as using related one or from the same table as fact will only show rows based on slicer selection. Then create this measure:

 

Disconnected Total Revenue = 
VAR _SelectedPeriod =
    MIN ( DisconnectedDate[Date] )
VAR _P10 =
    EOMONTH ( _SelectedPeriod, 9 )
RETURN
    CALCULATE (
        [Total Revenue],
        KEEPFILTERS ( Dates[Date] >= _SelectedPeriod && Dates[Date] <= _P10 )
    )

danextian_1-1756702970402.gif

Please see the attached pbix.

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

@danextian ,

Thank you so much!! This is working😊

Shahid12523
Community Champion
Community Champion

To show only 10 month columns after the selected slicer month in your matrix:
- Create a calculated column in CalendarTable:


ShowMonthFlag =
VAR SelectedMonth =
CALCULATE (
MINX (
FILTER (
ALL('Upcoming Date'),
'Upcoming Date'[MonthYear] = SELECTEDVALUE('Upcoming Date'[MonthYear])
),
'Upcoming Date'[Date]
)
)
RETURN
IF (
CalendarTable[Date] >= SelectedMonth &&
CalendarTable[Date] < EDATE(SelectedMonth, 10),
1,
0
)

 


- Add ShowMonthFlag to your matrix visual-level filters and set it to 1.
That’ll restrict columns to just the 10 months starting from the selected slicer value.

Shahed Shaikh

You're seriously telling OP to create a calculated column?  Calculated columns are not aware of slicer selections. They are computed once when data is loaded, refreshed or the formula is modified. Use AI responsibily. Validate and not just copy-paste whatever it spits.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
Aburar_123
Solution Supplier
Solution Supplier

Hi @WinterGarden ,

 

Please follow the below steps.

 

My data model:

Aburar_123_0-1756698497861.png

Dim Date1 = ADDCOLUMNS(CALENDARAUTO(12),
"Year Month",YEAR([Date])&"-"&FORMAT(MONTH([Date]),"0#"),
"Year Month Sort",YEAR([Date])&FORMAT(MONTH([Date]),"0#")
)
 
Dim Date2 = ADDCOLUMNS(CALENDARAUTO(12),
"Year Month",YEAR([Date])&"-"&FORMAT(MONTH([Date]),"0#"),
"Year Month Sort",YEAR([Date])&FORMAT(MONTH([Date]),"0#")
)
 
Note : Make sure 'Year Month Sort' column should be whole Number format and Sort the 'Year Month' column by 'Year Month Sort' column.
 
Just create the below measure that you are going to use it in the values card in the Matrix visual,
Sales_Last_10Months = CALCULATE(SUM(FACT_Orders[Sales]),FILTER('Dim Date1','Dim Date1'[Year Month Sort]>=MAX('Dim Date2'[Year Month Sort]) && 'Dim Date1'[Year Month Sort]< MAX('Dim Date2'[Year Month Sort])+10))
 
Aburar_123_1-1756698808390.png

 

In this case you dont need to create any flag column to filter in the visual filter page.

 

Thanks.

Hi @Aburar_123 ,

Tried to implement this, but it is not showing next year data..
eg if 2025-04 is selected , then it should show columns from 2025-04 to 2026-01 right?

WinterGarden_0-1756706907662.png



WinterGarden_1-1756706946746.png

 

 

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/
Jihwan_Kim
Super User
Super User

Hi,

One of ways is to create disconnected slicer table and calculation group to filter the visualization.

I tried to create a sample pbix file, and please check the below picture and the attached pbix file.

 

Jihwan_Kim_1-1756695529386.png

 

 

Jihwan_Kim_0-1756695510239.png

 

 

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Hi @Jihwan_Kim ,
Thank you, but the ask is to show the month year in columns.. 
in the rows... we are displaying project, category and in the values we are using a value column..
based on the month year selected , i wanted to show 10 months on or after that selected month in the columns of that matrix.

thanks

FBergamaschi
Solution Sage
Solution Sage

Hi @WinterGarden 

you need to use the YearMonthNr column that you already have (why the -1 in its definition?) and include it into your disconnected table, that will simplify the issue
 
Upcoming Date =
ADDCOLUMNS (
    CALENDAR (DATE(2025,1,1), DATE(2035,12,31)),  -- adjust range
    "MonthYear"FORMAT([Date]"mmm-yy"),
    "FY",FORMAT([Date]"yyyy"),
     "YearMonthNum", YEAR([Date]) * 12 + MONTH([Date]) - 1
)
 
ShowInMatrix =
VAR SelectedYearMonthNr  = SELECTEDVALUE('Upcoming Date'[YearMonthNum])
VAR MaxYearMonthNr = SelectedYearMonthNr + 10
Var CurrentYearMonthNrInMatrix = SELECTEDVALUE ( 'Calendar Table'[YearMonthNum] )
RETURN
IF (
    NOT ISBLANK(SelectedYearMonthNr) &&
    CurrentYearMonthNrInMatrix >= SelectedYearMonthNr &&
    CurrentYearMonthNrInMatrix < MaxYearMonth,
    1,
    0
)

If this helped, please consider giving kudos and mark as a solution

@me in replies or I'll lose your thread

Want to check your DAX skills? Answer my biweekly DAX challenges on the kubisco Linkedin page

Consider voting this Power BI idea

Francesco Bergamaschi

MBA, M.Eng, M.Econ, Professor of BI

Hi @FBergamaschi ,

I've created the specified column and updated the measure as well.. then i add the measure "ShowInMatrix" in the filter pane of that matrix visual..

still the months columns are not getting filtered. Also the row values are now coming as blank. PLease find the below screenshot.

WinterGarden_0-1756701822870.png

 

 

Hello @WinterGarden,

weird as I tried and it works

 

Can you check the file I put here and confirm ir works or not?

 

https://drive.google.com/drive/folders/1NTqfUR6s5mNslyr9QpI-tif9I-Vp4Y3S?usp=sharing

 

This is my result

 

FBergamaschi_0-1756734526677.png

 

With this approach you can change the measure at your will in the visual. Another approach I like is a calculation group, in case.

 

Thanks

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