Forum Discussion
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.
I want to see the following two columns in the table view next to the $/LBS column
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!
Hi, Anonymous
Please try the following methods.
Sample Data:
$/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 PrevMonthPecent 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)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.
3 Replies
- v-zhangtiCommunity Support
Hi, Anonymous
Please try the following methods.
Sample Data:
$/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 PrevMonthPecent 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)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.
- amitchandakSuper 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- AnonymousNot 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.