Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to sum a set of values that lie between a start date and an end date?

Tags:

qlikview

I have created two dropdown list

 1. start date 
 2. end date

I am using MySQL database as a source and I have a table called generation having columns like (date , generation, turbine_id).

After selecting the start date and end date, I need to sum the corresponding values that lie between the two dates:

sum({<Date= {"<=$(=vStartDate)>=$(=vEndDate)"}> } Target)
like image 868
Ranjit Kumar Avatar asked Nov 05 '12 10:11

Ranjit Kumar


1 Answers

I see that you already made two variables, vStartDate and vEndDate, So you can manipulate them using a Calendar or an Input Box.

In this case your set expression is almost good. It sould look like this:

Sum({$<Date = {">=$(=vStartDate)<=$(=vEndDate)"}>} Target)

So in the curly bracket it starts with a $ sign, which represents the current selection, which will be filtered by the expression. In the double quotes you tell that the value of Date should be bigger or equal than the evaluated =vStartDate expression (evaluation is done by using a dollar-sign expression), and less than vEndDate. This is how it works.

like image 136
Imre Greilich Avatar answered Sep 23 '22 00:09

Imre Greilich