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.
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:
Solved! Go to Solution.
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
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
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.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
108 | |
106 | |
87 | |
77 | |
69 |
User | Count |
---|---|
124 | |
112 | |
94 | |
84 | |
75 |