Forum Discussion
tracytran91
5 years agoHelper III
Dynamic % Growth based on selected date slicer
Hi Folks, I would like to calculate the growth percentage (%) based on selected date slicer. Any help is high appreciated. Thank you in advance.
- 5 years ago
Hi tracytran91 ,
Suppose you are comparing the past 3 months with the current month, you can create a measure like this:
Growth% = VAR _mindate = CALCULATE ( MIN ( 'Table'[Date] ), ALLSELECTED ( 'Table'[Date] ) ) VAR _maxdate = CALCULATE ( MAX ( 'Table'[Date] ), ALLSELECTED ( 'Table'[Date] ) ) VAR last3month = CALCULATE ( SUM ( 'Table'[value] ), FILTER ( ALL ( 'Table' ), 'Table'[Date] >= _mindate && 'Table'[Date] <= _maxdate ) ) VAR currentmonth = CALCULATE ( SUM ( 'Table'[value] ), FILTER ( ALL ( 'Table' ), YEAR ( 'Table'[Date] ) = YEAR ( TODAY () ) && MONTH ( 'Table'[Date] ) = MONTH ( TODAY () ) ) ) RETURN DIVIDE ( currentmonth - last3month, last3month )Attached a sample file in the below, hopes to help you.
Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
v-yingjl
5 years agoCommunity Support
Hi tracytran91 ,
You can create a date table based on your source table and use it as a slicer:
Date = DISTINCT('Table'[Date])
Create a measure like this to calculate growth%:
Growth% =
VAR _selectdatevalue =
CALCULATE (
SUM ( 'Table'[value] ),
FILTER ( ALL ( 'Table' ), 'Table'[Date] = SELECTEDVALUE ( 'Date'[Date] ) )
)
RETURN
DIVIDE ( SUM ( 'Table'[value] ) - _selectdatevalue, SUM ( 'Table'[value] ) )
Attached a sample file in the below, hopes to help you.
Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.