Forum Discussion
Dynamic % Growth based on selected date slicer
- 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 amitchandak Thank for your solution. Unfortunately, the result is not as I expected.
I would like selected date on slicer such as "last 3 months", "last 6 months", "last 1 year"..... and it shows up the % growth regarding to the selected date.
- amitchandak5 years agoSuper User
tracytran91 , do want like this diff 3 vs 3 before it
Rolling 3 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date ],eomonth(MAX('Date'[Date]),0),-3,MONTH))
Rolling 3 before 3 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date ],eomonth(MAX('Date'[Date]),-3),-3,MONTH))or
Rolling 3 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date ],MAX('Date'[Date]),-3,MONTH))
Rolling 3 before 3 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date ],MAXX('Date',dateadd('Date'[Date],-3,month)),-3,MONTH)) - v-yingjl5 years agoCommunity Support
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.