Forum Discussion
MSC
Helper III
5 years agoCalculate sales growth using calculated column
Hi everyone! I'd like to create a calculated column which returns the growth rate of my product sales. I've already managed to do with by means of measures but failed with a calculated column. Fo...
- 5 years ago
MSC ,
Try this code for a new calculated column:
Growth = VAR _lastDate = MAXX(FILTER('Table', 'Table'[Product] = EARLIER('Table'[Product]) && [Date] < EARLIER('Table'[Date])), 'Table'[Date]) VAR _lastValue = CALCULATE(SUM('Table'[Sales]), FILTER('Table', 'Table'[Product] = EARLIER('Table'[Product]) && [Date] = _lastDate)) RETURN IF(_lastValue <> BLANK(), ('Table'[Sales] - _lastValue) / _lastValue)
Ashish_Mathur
Super User
5 years agoWhy do you want a calculated column solution? Why not a measure?
- MSC5 years ago
Helper III
Hi Ashish_Mathur !
Initially, I preferred a column solution because I'd found a workaround for a similar problem which was based on calculated columns.However, if there's a measure solution which returns the average category growth rate of the product I selected, this would be fine as well.