Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Identifying shifts in data trend

Hello all!  I'm fairly new on PowerBI development and currently I am facing an issue that I am not sure on how to solve it (actually I am not even sure if it is solvable).   I have a certain datas...
  • camargos88's avatar
    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
  • az38's avatar
    az38
    6 years ago

    camargos88 

    had a great solution, accept it as solution

    for your need try

    RETURN 
    IF(_actualValue < _previousValue; _actualValue ; 0)