Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Next and previous day values

Hello to PowerBI community, I have 2 tables   1st Code Description 1 x 2 y 3 z 4 w   2nd Date Code Value 3/5/2021 1 58 3/5/2021 2 65 3/5/2021 3 12 ...
  • Anonymous's avatar
    Anonymous
    5 years ago

    Hi Anonymous ,

     

    Check the measure and the result.

    Measure = 
    var _next = CALCULATE(SUM('Table 2'[Value]),FILTER(ALL('Table 2'),'Table 2'[Date]=SELECTEDVALUE('Table 2'[Date])+1&&'Table 2'[Code]=SELECTEDVALUE('Table 1'[Code])))
    var _previous = CALCULATE(SUM('Table 2'[Value]),FILTER(ALL('Table 2'),'Table 2'[Date]=SELECTEDVALUE('Table 2'[Date])-1&&'Table 2'[Code]=SELECTEDVALUE('Table 1'[Code])))
    return
    IF(_next=0,_previous,_next)

    If the result is not what you want, please show the expected result.

     

    Best Regards,

    Jay