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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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 ) )

 

 

Helpful resources

Announcements
Sept PBI Carousel

Power BI Monthly Update - September 2024

Check out the September 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

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