Sometimes as a SAC developer you would receive request from your business team to build dashboards encapsulating an aggregation function like runningsum(). This blog covers a specific case wherein
- The scope is limited to SAC acquired connections involving an SAC model creation (rather than live connections). This specific case if pertaining but not limiting to OData service as source.
- We are trying to achieve the cumulative sum in a chart rather than a table (wherein we have inbuilt cumulative functions).
- The cumulative sum should be continuous and can seamlessly across year boundaries E.g. Dec 2020 through Jan 2021 etc. This would rule out the use of YTD, MTD etc. aggregation calculation leveraged in time series plots
Sample Use case: Showing daily count of defects opened during HyperCare phase of a project along with a running sum of backlog. Here:
- Defects opened = Number of defects opened per day
- Defect Backlog = A – B = sum (All tickets opened till date) – sum (All tickets closed till date)
Even though we do not have an equivalent out of the box cumulative aggregation function to leverage in a user defined variable, SAP Analytics Cloud still gives us the flexibility of simulating the function at a model level.
Here, the approach is two-fold
Step1: F1 = Calculate A-B at daily level (@SAC Model)
Step2: F2 = Apply LOOKUP() function on the above calculation i.e. F1(@SAC Model)
Navigate to the Model >Account > Add Member (under Edit) > Add Formula for the Member
The respective columns for Step1 and Step2 are then created as members of account dimension
Now, let us understand the LOOKUP function to code for step 2
Decoding the Lookup function for cumulation functionality:
Part1: Overview of LOOKUP function
The LOOKUP function is used to aggregate the account member in the context of a given point of view (POV). Click here to learn more about the function from SAP Help Portal
Syntax: LOOKUP([<account member>], [<POV>], [<Ignore Dimension>])
Part2: Writing Dynamic time navigation functions for given POV
Backlog = [ Open Incident Count] – [Resolved Incident Count]
LOOKUP([Backlog] ,[d/Week_End_Date]=Lastperiods(“Day”,365 ))
The ‘Lastperiods’ time navigation function is the key to cumulate the daily backlog values. Here, we have restricted the cumulation to 365 days of a year, Ideally this value would vary depending upon the requirement and can be changed accordingly. The output of the function is shown below.
In the above chart, the blue bar represents the opened tickets at a weekly level. The orange line represents the cumulation output of the LOOKUP function
E.g.
Open Tickets for week of March 29th =6 –> (A)
Resolved tickets for week of April 5th = 0 –>(B)
Open Tickets for week of April 5th = 4 –>(C)
Backlog for Week of April 5th = (A)-(B)+(C) = 6-0+4 = 10
Here the LOOKUP function cumulates all open tickets (for 3/22 , 3/29, 4/5) then substracts all closed tickets (for 3/22 , 3/29, 4/5) to simulate the above number (10). This is because the it acts on top of the Account member Backlog = [ Open Incident Count] – [Resolved Incident Count]
In this way we can centralize the cumulation at a model level which can then be leveraged across multiple dashboards.
Regards,
Dhyanesh