Forum Discussion

taylorie's avatar
taylorie
Frequent Visitor
3 years ago
Solved

calculate variance between two dates based on two values

Hi    I have two tables as per below, I need to calculate the difference between "daily sales" before and after the "Service" was done, using "Bsc Start" and "COM date". The only constant in both t...
  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi taylorie ,

     

    According to your description, here are my steps you can follow as a solution.

    (1) My test data is the same as yours.

    (2) We can create a measure. 

     

    Variance = 
    var a=MINX(FILTER(ALL('Table (2)'),[Corporate ref]=MAX('Table'[Corporate ref])&&[Date]>=MAX('Table'[Bsc start])),[Date])
    var b=CALCULATE(SUM('Table (2)'[Daily sale]),'Table (2)'[Date]=a)
    return ABS(CALCULATE(SUM('Table (2)'[Daily sale]),'Table (2)'[Date]=a+1)-b)

     

    (3) Then the result is as follows.

    Best Regards,

    Neeko Tang

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