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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
filipebodas
Helper I
Helper I

Month over Month % Variance

Hi everyone,

 

I want to calculate a month over month variation, but I want to lock the current value of the last and second last month, even if my date slicer has two or more months.

 

For example, if my matrix table has:

 

YearTotal Orders
  •   2021
10.000
             November 5.500
             December4.500
  •   2022
7.000
             January7.000

 

I want to lock the values of the latest month and second latest month of the interval everytime I move the slicer on my date so I can calculate the variation over month over month.

 

YearTotal OrdersLast Month Orders Second Last Month Orders
  •   2021
10.000  
             November 5.5007.000               4.500
             December4.5007.000               4.500
  •   2022
7.000  
            January7.0007.0004.500

 

Then I can calculate the variance betwen the latest and second latest month of my interval

1 ACCEPTED SOLUTION
filipebodas
Helper I
Helper I

I solved. This is what I did:

Orders Month Over Month =

var most_recent_month_orders =
CALCULATE (
'Measure Table'[Total Orders],
'Calendar'[Month] = MONTH (MAX ('Calendar'[Date])),
'Calendar'[Year] = YEAR (MAX ('Calendar'[Date])))

var second_most_recent_month_orders =
CALCULATE (
'Measure Table'[Total Orders],
'Calendar'[Month] = MONTH (MAX ('Calendar'[End of Previous Month])),
'Calendar'[Year] = YEAR (MAX ('Calendar'[End of Previous Month])))

return
DIVIDE (
most_recent_month_orders,
second_most_recent_month_orders,
0) - 1



Whereas, Calendar'[End of Previous Month] is a column in my Calendar table I calculated by subtrating 1 day to the [Start of Month] column

View solution in original post

4 REPLIES 4
filipebodas
Helper I
Helper I

I solved. This is what I did:

Orders Month Over Month =

var most_recent_month_orders =
CALCULATE (
'Measure Table'[Total Orders],
'Calendar'[Month] = MONTH (MAX ('Calendar'[Date])),
'Calendar'[Year] = YEAR (MAX ('Calendar'[Date])))

var second_most_recent_month_orders =
CALCULATE (
'Measure Table'[Total Orders],
'Calendar'[Month] = MONTH (MAX ('Calendar'[End of Previous Month])),
'Calendar'[Year] = YEAR (MAX ('Calendar'[End of Previous Month])))

return
DIVIDE (
most_recent_month_orders,
second_most_recent_month_orders,
0) - 1



Whereas, Calendar'[End of Previous Month] is a column in my Calendar table I calculated by subtrating 1 day to the [Start of Month] column
Whitewater100
Solution Sage
Solution Sage

Hi: This has some additional control tools in your date table. Does this work for you?

https://drive.google.com/file/d/1Wrt1MD9hqoezFCfZYCftUHDK0FRO8nDG/view?usp=sharing 

It appears to do so, but your MoM metrics always returns blank regardless of the interval date

Hi:

Can you take another look? I manually entered only three months of data. If more months had data it will work for more months. Currenly Nov '21 thru Jan '22 are populated.  See image below. Slicer is working.

Are you saying you always want to see the last 30 days compared to days 60-31 ago?

What result do you expect?

Thanks

Whitewater100_0-1646514211164.png

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors