Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Calculation with multible variables in time

Hi all,   I am facing a problem in my Power BI File.   I am making a calculation based on some variable. What I am doing is comparing two numbers (current and past period) with each other to calc...
  • v-zhangti's avatar
    v-zhangti
    4 years ago

    Hi, Anonymous 

     

    Based on the data you provide, you can try the following methods.

    Current value = SUM(Data[Value])
    Previous value = 
    Var PrevDate=MAXX(FILTER(ALL('Data'[Date],Data[Year]),'Data'[Date]<SELECTEDVALUE('Data'[Date])&&[Year]=SELECTEDVALUE(Data[Year])),'Data'[Date])
    Var Prevalue=CALCULATE([Current value],FILTER(ALL(Data),[Date]=PrevDate))
    Return
    Prevalue
    Outcome = IF([Previous value]<>BLANK(), [Current value]-[Previous value])

    The result of the calculation is different from the result you expect. Consider if there is a problem with your desired result calculation?

     

    Let me give you an example.

    But in your results.

    Please check if there is a problem with your result calculation in Excel, thank you.

     

    Best Regards,

    Community Support Team _Charlotte

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.