# QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
Our next Qlik Insider session will cover new key capabilities. Join us August 11th REGISTER TODAY
cancel
Showing results for
Did you mean:
Contributor III

## Set Analysis with variable and date period greater than less than

Dear Masters out there !

I have 2 variables v_DateFrom and v_DateTo, chosen/assigned from Calendar object . Then i need to count total man hrs worked for a list of employee within that date range . The below is not working in my expression . Please assist

Sum({<[EMP_NM]= {'ABC','XYZ'},APPROVEDDATE = {">=\$(=Date(v_DateFrom))<=\$(=(v_DateTo))"}>}MANHRS)

Thanks !

Lim

Labels (3)

• ### variable

1 Solution

Accepted Solutions
Specialist

Hi,

Sorry I cannot share qvw, but have a look on my exp. Reason why direct date is not working with set analysis because your time is different for same dates. We need to use Floor() for the same.

Script :

```LOAD EMP_NM,
MANHRS,
//APPROVEDDATE as appDates
Floor(APPROVEDDATE) as appDates
FROM
(biff, embedded labels, table is [Sheet 1\$]);

```

Variables :

```vDateFrom = appDates
vDateTo = appDates```

Now use this expression with dimension EMP_NM,

```= sum({<appDates = {">=\$(=vDateFrom)<=\$(=vDateTo)"}>}MANHRS)
```

-Shubham

24 Replies
Perhaps this
Sum({<[EMP_NM]= {'ABC','XYZ'},APPROVEDDATE = {">=\$(=Date(\$(v_DateFrom)))<=\$(=(\$(v_DateTo)))"}>}MANHRS)
Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)
Contributor III
Author

Errmmm, thanks loveisfail , the expression show OK , but i do not see any result . It suppose to be some data shown

Specialist

Hi @limfungkeat,

=Sum({<APPROVEDDATE  ={">=\$(=v_DateFrom)<=\$(=v_DateTo)"},[EMP_NM]={ 'ABC','XYZ'}>} MANHRS)

Try this, it should work. And in variable itself make it Date(v_DateFrom) rather in set analysis.

- Shubham

Contributor III
Author

Dear all / Shubham

i attached my qvw file and the data source i extracted from my oracle table . The replies given so far is still not working ...Looking forward to some solutions Thanks !

Specialist

It is working in my case, try it

=sum({<vDate = {">=\$(=vDateFrom)<=\$(=vDateTo)"},EMP_NM={'A','B'}>}MANHRS)

It is creating issue in set analysis because of APPROVEDDATE date format, I changed it then also it wasn't working.

It works in simple exp like =sum(if(APPROVEDDATE>=vDateFrom and appDates<=vDateTo,MANHRS)) but not in set analysis.

So create vDate variable for APPROVEDDATE - vDate =date(APPROVEDDATE)

Regards,

Shubham

Contributor III
Author
 EMP_NM MANHRS APPROVEDDATE A 8 01/15/2019 15:34:00 A 8 02/15/2019 15:34:01 A 8 03/01/2019 15:34:01 A 8 03/15/2019 15:34:02 A 4 03/18/2019 15:34:02

Hi Shubham - thank you so much for proactively help to resolve my problem , refer the above data set , by using the below exp from you (where i have created the variable vDate =date(APPROVEDDATE) )

=sum({<vDate = {">=\$(=vDateFrom)<=\$(=vDateTo)"},EMP_NM={'A'}>}MANHRS)

so, when i select the date from the calendar object - say 1/3/2018 - 31/3/2018 , i am expecting my pivot table to show

only 20 manhrs , instead of  36 manhrs ...

Specialist

HI Limfungkeat,

If you mention EMP='A' then it doesn't work. If you want to  show this in table according to EMP name then it will work, I have changed some values in data and look at the result in table.

Now according to above data and if I select date from - 01-03-2019 to 02-03-2019, then it should show 20.

Check and let me know.

-Shubham

Contributor III
Author

can i have your  version of the data source and the qvw file ? I will check and compare against mine . thanks

Specialist

Hi,

Sorry I cannot share qvw, but have a look on my exp. Reason why direct date is not working with set analysis because your time is different for same dates. We need to use Floor() for the same.

Script :

```LOAD EMP_NM,
MANHRS,
//APPROVEDDATE as appDates
Floor(APPROVEDDATE) as appDates
FROM
(biff, embedded labels, table is [Sheet 1\$]);

```

Variables :

```vDateFrom = appDates
vDateTo = appDates```

Now use this expression with dimension EMP_NM,

```= sum({<appDates = {">=\$(=vDateFrom)<=\$(=vDateTo)"}>}MANHRS)
```

-Shubham

Community Browser