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

Preparing for a certification exam? Ask exam experts all your questions on May 15th. Register now.

Reply
Anonymous
Not applicable

Make the matrix column interactive by defining what is current month

Hi all,

 

I have a Matrix visual in which it shows the following as columns:

 

Previous MonthsCurrent MonthMonth +1Month +2Month +3Month +4

 

This of course based on current month and has values underlying in the matrix for each month.

 

In this case, I want the client to be able to change the view and select what he sees as a current month. So for example define that the next month would be seen as current month. Is this possible to do in Power BI?

 

Thanks!

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

Hi @Anonymous ,

 

I create the sample data.

 

vkkfmsft_0-1652321321628.png

 

Then create these measures.

 

Previous Months = 
CALCULATE (
    SUM ( 'Table'[Value] ),
    FILTER ( ALL ( Dates ), Dates[Date] < MIN ( Dates[Date] ) )
)
Current Month = 
SUM ( 'Table'[Value] )
Month +1 = 
CALCULATE ( [Current Month], NEXTMONTH ( Dates[Date] ) )
Month +2 = 
CALCULATE ( [Month +1], NEXTMONTH ( Dates[Date] ) )
Month +3 = 
CALCULATE ( [Month +2], NEXTMONTH ( Dates[Date] ) )
Month +4 = 
CALCULATE ( [Month +3], NEXTMONTH ( Dates[Date] ) )

vkkfmsft_1-1652321480647.png

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
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

2 REPLIES 2
v-kkf-msft
Community Support
Community Support

Hi @Anonymous ,

 

I create the sample data.

 

vkkfmsft_0-1652321321628.png

 

Then create these measures.

 

Previous Months = 
CALCULATE (
    SUM ( 'Table'[Value] ),
    FILTER ( ALL ( Dates ), Dates[Date] < MIN ( Dates[Date] ) )
)
Current Month = 
SUM ( 'Table'[Value] )
Month +1 = 
CALCULATE ( [Current Month], NEXTMONTH ( Dates[Date] ) )
Month +2 = 
CALCULATE ( [Month +1], NEXTMONTH ( Dates[Date] ) )
Month +3 = 
CALCULATE ( [Month +2], NEXTMONTH ( Dates[Date] ) )
Month +4 = 
CALCULATE ( [Month +3], NEXTMONTH ( Dates[Date] ) )

vkkfmsft_1-1652321480647.png

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@Anonymous , You can measure like

 

This month Today =
var _min = eomonth(today(),-1)+1
var _max = eomonth(today(),0) //today()
return
CALCULATE(sum('Table'[Qty]), FILTER(('Date'),'Date'[Date] >= _min && 'Date'[Date] <=_max ) )

 

 

Last month Today =
var _min = eomonth(today(),-2)+1
var _max = eomonth(today(),-1) //today()
return
CALCULATE(sum('Table'[Qty]), FILTER(('Date'),'Date'[Date] >= _min && 'Date'[Date] <=_max ) )

 

 

Last to Last month Today =
var _min = eomonth(today(),-3)+1
var _max = eomonth(today(),-2) //today()
return
CALCULATE(sum('Table'[Qty]), FILTER(('Date'),'Date'[Date] >= _min && 'Date'[Date] <=_max ) )

 

based on selected data

MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))
last MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1,MONTH)))

previous month value = CALCULATE(sum('Table'[total hours value]),previousmonth('Date'[Date]))

 

2nd

last MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-2,MONTH)))

previous month value = CALCULATE(sum('Table'[total hours value]),previousmonth(dateadd('Date'[Date],-1,MONTH)))

 

 

Or

 

Last 5 month Today =
var _min = eomonth(today(),-5)+1
var _max = eomonth(today(),0) //today()
return
CALCULATE(sum('Table'[Qty]), FILTER(('Date'),'Date'[Date] >= _min && 'Date'[Date] <=_max ) )

 

 

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
PBIApril_Carousel

Power BI Monthly Update - April 2025

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

Notebook Gallery Carousel1

NEW! Community Notebooks Gallery

Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.

April2025 Carousel

Fabric Community Update - April 2025

Find out what's new and trending in the Fabric community.