Cognos Calculate Variance between dates

116 Views Asked by At

I have a "Master data" list like this :

Description Snapchot - Date Value
XXX 2023-01-05 150
XXX 2023-01-05 100
XXX 2023-01-06 350
XXX 2023-01-07 200

My goal is to create a Pivot table that calculates difference with day before :

     |  2023-01-05   |  2023-01-06   |  2023-01-07   |
     | Value | Diff. | Value | Diff. | Value | Diff. |
------------------------------------------------------
XXX  |  250  |   0   |  350  |  100  |  200  | -150  |

My problem is that I don't know how to make my calculation between two time periods :

(Value of [Snapchot - Date]) - (Value of ([Snapchot - Date] - 1 day)

What I tried is to make a second query where I use this expression :

add_days_ ([Snapchot - Date] ; -1)

This works but there's a mismatch in my values. I don't have the correct values for every dates as I have in my master list.

How can I create a query that gives me the value of the day before ? So that I can do :

[ValueCurrentDay] - [ValueDayBefore]
1

There are 1 best solutions below

3
Daniel Wagemann On

Based on the requirement you maybe looking for a running-difference. Have a look at the summary folder for the syntax of that summary function to see if it applies to your requirement.