Forum Discussion
Identifying shifts in data trend
- 6 years ago
Hi Anonymous ,
Try this code to create a new column:
Change =VAR _actualValue = 'Table'[value]VAR _date = 'Table'[date]VAR _lastDate = CALCULATE(MAX('Table'[date]); FILTER(ALL('Table'); 'Table'[date] < _date))VAR _previousValue = CALCULATE(DISTINCT('Table'[value]); FILTER(ALL('Table'); 'Table'[date] = _lastDate))RETURN IF(_actualValue < _previousValue; 1; 0)Ricardo - 6 years ago
had a great solution, accept it as solution
for your need try
RETURN IF(_actualValue < _previousValue; _actualValue ; 0)
Hi camargos88, thank you for the reply!!
I created this column and it worked returning "1" at the turning points. However, I wanted the column to return the date at which the shift occurred.
I changed the code in the RETURNIF as follows:
had a great solution, accept it as solution
for your need try
RETURN
IF(_actualValue < _previousValue; _actualValue ; 0)
- Anonymous6 years agoNot applicable
Thank you guys for the help.
az38 when I typed what you suggested, the return is "0" for all rows.
I figured that I have tried was not working because the column was configured as a number, and not a date. I changed this and it worked.
Thanks again!
- az386 years ago
Community Champion
Anonymous
it's great that you were able to deal with data type by yourself! well done!
- camargos886 years ago
Community Champion
Hi Anonymous ,
try this new code:
Change =VAR _actualValue = 'Table'[value]VAR _date = 'Table'[date]VAR _lastDate = CALCULATE(MAX('Table'[date]); FILTER(ALL('Table'); 'Table'[date] < _date))VAR _previousValue = CALCULATE(DISTINCT('Table'[value]); FILTER(ALL('Table'); 'Table'[date] = _lastDate))RETURN IF(_actualValue < _previousValue; _date; BLANK())Ricardo