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

Announcements
Qlik Connect 2026 Agenda Now Available: Explore Sessions
cancel
Showing results for 
Search instead for 
Did you mean: 
artav
Contributor II
Contributor II

Simulate a dynamic stock with variables

Hello everyone,

 

I want to simulate the behaviour of a battery on a network. In my entry data I have a timestamp associated to a value that is a need from the network (energy speaking). I have set up two measures : Need and Production that compute for each timestamp the total need and the production (that production is dependent on variables too).

I have created a variable vCapBat for the capacity of the battery, and two measures: Overproduction and Deficit which compare the need and the production.

I would like to simulate the behaviour of the battery in that way:

  • If Overproduction > 0,
    • If StockN-1 < Cap bat,
      • StockN = StockN-1 + SurplusElec until Cap bat
    • Else,
      • StockN = StockN-1
  • If Deficit > 0,
    • If StockN-1 > 0,
      • StockN = StockN - 1 - Deficit until 0
    • Else
      • StockN = StockN - 1 ( which is 0)

 

The closest I have reached in the Qlik syntax is:

RangeMin(
    vCapBat*1000000,
    RangeMax(
        0,
        RangeSum(
            Above(Overproduction - Deficit, 0, RowNo())
        ),
    )
)

 

But it is not so accurate, sometimes I have some overproduction that is not increasing that measure and I noticed that, if I put the RangeMax() part in a column, when there is overproduction it piles up to infinite, then the deficit makes it decrease but it has to go below the battery capacity to change the value of the whole RangeMin(), otherwise this one stays stuck at the battery capacity when the RangeMax() part > Battery capacity.

Labels (3)
0 Replies