Forum Discussion

Guyakobov's avatar
Guyakobov
Helper II
7 years ago

previous value

HI,

 

I would like to get the previous value.

so when I choose date 12.03.18 my profit will be -123960.45 and not -116778.37

http://prntscr.com/mtzgw5

 

Thanks 

8 Replies

  • PattemManohar's avatar
    PattemManohar
    Community Champion

    Guyakobov  Please try this as a New Measure

     

    Test231 = 
    VAR _PrevMax = CALCULATE(MAX(Test231PrevValDynamic[Time]),FILTER(ALL(Test231PrevValDynamic),Test231PrevValDynamic[Time]<SELECTEDVALUE(Test231PrevValDynamic[Time])))
    RETURN CALCULATE(FIRSTNONBLANK(Test231PrevValDynamic[Profit],0),Test231PrevValDynamic[Time] = _PrevMax)

    • Guyakobov's avatar
      Guyakobov
      Helper II

      HI,

       

      i wrote the measure like this : 

      floating pl is the table name.

       

      Test231 =
      VAR _PrevMax = CALCULATE(MAX('floating pl'[Time]),FILTER(ALL('floating pl'),'floating pl'[Time]<SELECTEDVALUE('floating pl'[Time])))
      RETURN CALCULATE(FIRSTNONBLANK('floating pl'[Profit],0),'floating pl'[Time] = _PrevMax)

       

       And my measure is null http://prntscr.com/mu15sc 

       

      BTW, there is more than one Login account.

       

      Thanks 

       

      • PattemManohar's avatar
        PattemManohar
        Community Champion

        Guyakobov  You are using date filter as range instead of list, as your requirement is to show the previous profit value based on the date selected. Also, use Login in your filter criteria if you want to include Login in the logic as below

         

        Test231 = 
        VAR _PrevMax = 
        CALCULATE(MAX(Test231PrevValDynamic[Time]),FILTER(ALL(Test231PrevValDynamic),Test231PrevValDynamic[Time]<SELECTEDVALUE(Test231PrevValDynamic[Time]) && Test231PrevValDynamic[Login] = SELECTEDVALUE(Test231PrevValDynamic[Login]) ))
        RETURN CALCULATE(FIRSTNONBLANK(Test231PrevValDynamic[Profit],0),Test231PrevValDynamic[Time] = _PrevMax)