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

Show Percent Change from Same Period Last Month in Table

Hello, 

 

I simply would like to show the percent change in view count between the current MTD and the previous month in the same period (if we were in the middle of the month, the percent change would compare days 1-15 of last month to days 1-15 this month). 

Is it possible to insert this value into a matrix where there are no dates fields included? I just want to show the report name and the percent change. 

Sample .pbix file here: PBI file 

KMcCarthy9_1-1685476770952.png

 

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

Hi , @KMcCarthy9 

Thanks for your sample data first!

According to your description, you want to calculate the current and previoud month MTD count.

Here are the steps you can refer to :
(1)We can create three measures like this:

CurMonth_Count = 
//you can repalce this to today
var _today = DATE(2023,5,30)
var _t =  FILTER( 'View Count' , YEAR('View Count'[Date]) = YEAR( _today)  &&  MONTH('View Count'[Date])  = MONTH(_today) && 'View Count'[Date]<=_today)


return
SUMX(_t ,[ViewCount])+0
PreviosMonth_Count = 
//you can repalce this to today
var _today  = DATE(2023,5,30)
var _pre_month =  EDATE(_today,-1)
var _t =  FILTER( 'View Count' , YEAR('View Count'[Date]) = YEAR( _pre_month)  &&  MONTH('View Count'[Date])  = MONTH(_pre_month) && 'View Count'[Date]<=_pre_month)

 return
SUMX(_t ,[ViewCount])+0

 

Measure = DIVIDE( [CurMonth_Count]-[PreviosMonth_Count] , [PreviosMonth_Count])

 

Then we can get this result as follows:

vyueyunzhmsft_0-1685586881146.png

 

 

 

 

If this method does not meet your needs, you can provide us with your special sample data and the desired output sample data in the form of tables, so that we can better help you solve the problem. (You can also upload you sample .pbix [without sensitive data] to the OneDrive and share with the OneDrive link to me ! )

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

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

5 REPLIES 5
KMcCarthy9
Helper IV
Helper IV

@v-yueyunzh-msft Thank you so much for taking the time to do this! This is a great help! 

v-yueyunzh-msft
Community Support
Community Support

Hi , @KMcCarthy9 

Thanks for your sample data first!

According to your description, you want to calculate the current and previoud month MTD count.

Here are the steps you can refer to :
(1)We can create three measures like this:

CurMonth_Count = 
//you can repalce this to today
var _today = DATE(2023,5,30)
var _t =  FILTER( 'View Count' , YEAR('View Count'[Date]) = YEAR( _today)  &&  MONTH('View Count'[Date])  = MONTH(_today) && 'View Count'[Date]<=_today)


return
SUMX(_t ,[ViewCount])+0
PreviosMonth_Count = 
//you can repalce this to today
var _today  = DATE(2023,5,30)
var _pre_month =  EDATE(_today,-1)
var _t =  FILTER( 'View Count' , YEAR('View Count'[Date]) = YEAR( _pre_month)  &&  MONTH('View Count'[Date])  = MONTH(_pre_month) && 'View Count'[Date]<=_pre_month)

 return
SUMX(_t ,[ViewCount])+0

 

Measure = DIVIDE( [CurMonth_Count]-[PreviosMonth_Count] , [PreviosMonth_Count])

 

Then we can get this result as follows:

vyueyunzhmsft_0-1685586881146.png

 

 

 

 

If this method does not meet your needs, you can provide us with your special sample data and the desired output sample data in the form of tables, so that we can better help you solve the problem. (You can also upload you sample .pbix [without sensitive data] to the OneDrive and share with the OneDrive link to me ! )

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

 

@v-yueyunzh-msft If I wanted to update this to compare the prior 2 months against each other, how would I do that?
So for today, the data would show full month April compared to full month May.

Thank you! 

Hi , @KMcCarthy9 

If you want to get the full month , you just need to delete the "&& 'View Count'[Date]<=_pre_month" in the dax code , like this :

CurMonth_Count = 
//you can repalce this to today
var _today = DATE(2023,5,30)
var _t =  FILTER( 'View Count' , YEAR('View Count'[Date]) = YEAR( _today)  &&  MONTH('View Count'[Date])  = MONTH(_today))

return
SUMX(_t ,[ViewCount])+0
PreviosMonth_Count = 
//you can repalce this to today
var _today  = DATE(2023,5,30)
var _pre_month =  EDATE(_today,-1)
var _t =  FILTER( 'View Count' , YEAR('View Count'[Date]) = YEAR( _pre_month)  &&  MONTH('View Count'[Date])  = MONTH(_pre_month) )
 return
SUMX(_t ,[ViewCount])+0

 

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

@v-yueyunzh-msft Thank you! I had to also make 1 other small adjustment - add in a '-2' at the very end of the CurMonth_Count to get 2 months back (which obviously doesn't make this the current month anymore like the initial name of the measure suggests just to clear any confusion for other readers).

CurMonth_Count = 
//you can repalce this to today
var _today = DATE(2023,5,30)
var _t = FILTER(ES_UsageMetricsPBI, YEAR(ES_UsageMetricsPBI[Date]) = YEAR(_today) && MONTH(ES_UsageMetricsPBI[Date]) = MONTH(_today)-2)

return
SUMX(_t ,[ViewCount])+0

 

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.