Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
110
Creator
Creator

Cumulative Sum in load script using Peek?

So I wanted to roll up the entitlement consumption in the consumption monitor to see at what point in month we reached 50%/75% of our capcity.

I'm just tacking this on the end so as not to interfere with the usual QVD incremental load, however it seems to be duplicating rows and not summing as expected.

 

I first create a table that sums the CapacityUsed by Date & AppID , then use Peek.

[Cumulative]:

NoConcatenate

LOAD 
    appId,
    MonthStart( Date(Timestamp#(endTime, 'YYYY-MM-DDThh:mm:ss.fffZ'))) AS CMLMonth, 
    Date(Timestamp#(endTime, 'YYYY-MM-DDThh:mm:ss.fffZ')) AS DateOnly,  // Extracts date portion from endTime
    Sum(capacityUsed) AS TotalCapacityUsed

RESIDENT Entitlement_Consumption

GROUP BY appId, Date(Timestamp#(endTime, 'YYYY-MM-DDThh:mm:ss.fffZ')),  MonthStart( Date(Timestamp#(endTime, 'YYYY-MM-DDThh:mm:ss.fffZ')));


[MonthlyCumulative]:

NoConcatenate

LOAD
    appId,DateOnly as CMLDate,
    CMLMonth,
       // Get the month start for grouping by month
    If(CMLMonth = Peek('CMLMonth')AND appId = Peek('appId'),
        Peek('CumulativeCapacityUsed') + TotalCapacityUsed,TotalCapacityUsed) AS CumulativeCapacityUsed    // Calculate cumulative sum

RESIDENT [Cumulative]
ORDER BY DateOnly,appId, CMLMonth;


Drop Table Cumulative;




What I should eventually get is akin to the below

110_0-1730804675267.png

 

However it doesn't seem to be accumulating 

110_1-1730804725457.png

 

 

Labels (1)
10 Replies
110
Creator
Creator
Author

Thanks @Kushal_Chawda   - that worked - I can now highlight where the running sum intersects the threshold.  Great stuff, and thanks again for your help!

As below- conditional colouring where intersections hit:-

110_1-1732619803477.png