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
jbarnard2
Frequent Visitor

KPI with % change

I am looking to build some KPIs with a % change from the most recent complete period (month or quarter) to a previous period (either previous quarter/month or same quarter/month from previous year), but everything I've found in the community and elsewhere online does not quite work. Here is an example of what I'm trying to achieve:

 

jbarnard2_0-1698696779673.png
% change calculated with the formula: (Current Period - Previous Period) / Previous Period
 
One of the requirements is that these KPIs sit on the top of a dashboard with other components that show the entire 5 quarter timeframe, and that it dynamically will select the last complete quarter/month or the same one from last year when this is updated. The metric doesn't have to be in the same box as the % change, though.
 
I'm relatively new to PBI - but this was pretty straightforward in Tableau: make a table calculation for % change, then use a lookup function to look back 1 or 5 quarters, depending on input from a parameter switch. If anyone has some insight on how to think about this differently in PBI, it would be greatly appreciated. 
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

Measure =

var _current = Switch( selectedvalue(Period[Period]) ,

"Month", QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(('Date'[Date]))),

"Quarter", QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESQTD(('Date'[Date]))),

"Year", QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(('Date'[Date])))

)


var _prior = Switch( selectedvalue(Period[Period]) ,

"Month", QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1,Month))),

"Quarter", QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESQTD(dateadd('Date'[Date],-1,QUARTER))),

"Year", QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd('Date'[Date],-1,Year)))

)
return
divide( _current - _prior, _prior)

 

refer

https://medium.com/chandakamit/power-bi-when-i-felt-lazy-and-i-needed-too-many-measures-ed8de20d9f79

 

https://community.powerbi.com/t5/Desktop/Required-custom-date-Slicer-Last-7-days-last-15-days-last-3...

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

Measure =

var _current = Switch( selectedvalue(Period[Period]) ,

"Month", QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(('Date'[Date]))),

"Quarter", QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESQTD(('Date'[Date]))),

"Year", QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(('Date'[Date])))

)


var _prior = Switch( selectedvalue(Period[Period]) ,

"Month", QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1,Month))),

"Quarter", QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESQTD(dateadd('Date'[Date],-1,QUARTER))),

"Year", QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd('Date'[Date],-1,Year)))

)
return
divide( _current - _prior, _prior)

 

refer

https://medium.com/chandakamit/power-bi-when-i-felt-lazy-and-i-needed-too-many-measures-ed8de20d9f79

 

https://community.powerbi.com/t5/Desktop/Required-custom-date-Slicer-Last-7-days-last-15-days-last-3...

thanks for the quick reply! Maybe I don't understand how these functions work, but I need entire previous quarters, not quarter or month to date.

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.