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
Anonymous
Not applicable

Creating Percent change Measure from a Measure

 I have this table, and $/LBS is a measure that I created simply by dividing $ and LBS column. 

ayush_gupta_0-1656514692788.png

I want to see the following two columns in the table view next to the $/LBS column

ayush_gupta_2-1656515440094.png

Pecent Change (Previous Month) was calculated by =(Month-Prev Month) / Prev Month

Pecent Change (Compared to Jan) was calculated by= (Month - $Jan) / $Jan

 

If anyone could show me how to do this in PowerBi, I would appreciate it!

 

1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @Anonymous 

 

Please try the following methods.

Sample Data:

vzhangti_0-1656943180147.png

$/LBS = DIVIDE(SELECTEDVALUE('Table'[$]),SELECTEDVALUE('Table'[LBS]))
Prev Month = 
VAR PrevDate=MAXX(FILTER(ALL('Table'[Date]),[Date]<SELECTEDVALUE('Table'[Date])),[Date])
Var PrevMonth=CALCULATE([$/LBS],FILTER(ALL('Table'),[Date]=PrevDate))
Return
PrevMonth
Pecent Change (Previous Month) = DIVIDE([$/LBS]-[Prev Month],[Prev Month])
Pecent Change (Compared to Jan) = 
Var Jan=CALCULATE([$/LBS],FILTER(ALL('Table'),MONTH([Date])=1))
return
DIVIDE([$/LBS]-Jan,Jan)

vzhangti_1-1656943327682.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

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

3 REPLIES 3
v-zhangti
Community Support
Community Support

Hi, @Anonymous 

 

Please try the following methods.

Sample Data:

vzhangti_0-1656943180147.png

$/LBS = DIVIDE(SELECTEDVALUE('Table'[$]),SELECTEDVALUE('Table'[LBS]))
Prev Month = 
VAR PrevDate=MAXX(FILTER(ALL('Table'[Date]),[Date]<SELECTEDVALUE('Table'[Date])),[Date])
Var PrevMonth=CALCULATE([$/LBS],FILTER(ALL('Table'),[Date]=PrevDate))
Return
PrevMonth
Pecent Change (Previous Month) = DIVIDE([$/LBS]-[Prev Month],[Prev Month])
Pecent Change (Compared to Jan) = 
Var Jan=CALCULATE([$/LBS],FILTER(ALL('Table'),MONTH([Date])=1))
return
DIVIDE([$/LBS]-Jan,Jan)

vzhangti_1-1656943327682.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

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 use time intelligence to get it , if you have date table

 

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

 

 

 

Or have month year table with month rank

Month Rank = RANKX(all('Date'),'Date'[Month Start date],,ASC,Dense)

 

This Month = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Month Rank]=max('Date'[Month Rank])))
Last Month = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Month Rank]=max('Date'[Month Rank])-1))

 

Time Intelligence, DATESMTD, DATESQTD, DATESYTD, Week On Week, Week Till Date, Custom Period on Period,
Custom Period till date: https://youtu.be/aU2aKbnHuWs&t=145s

 

Anonymous
Not applicable

"Sum" also works for a column in a data table. $/LBS is a measure that you see in a table visualization. So I can't use the Sum function to do this, unfortunatley.

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.