# QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Announcements
Highlighted
New Contributor

## Current sales & previous sales calculation

I have date  dimension and i want to calculate current sales & previous sales from one date to another date.

In that case, how can i write the  exact expression for that???

-[Process Date Time] is my date dimension.

if ([Process Date Time] between ?Start? and ? End?) then ([Item Gross Price]) else (0)---this is my Sql Query, so how can i implement this into Qlik.

Tags (4)
7 Replies
Honored Contributor III

## Re: Current sales & previous sales calculation

Try this

with variable

if(

[Process Date Time] >\$(vMinDate) and  [Process Date Time] <\$(vMaxDate) ,

sum( [Item Gross Price]))  , 0)

without variable

if(

[Process Date Time] >'2012-02-02' and  [Process Date Time] <'2012-02-28' ,

sum( [Item Gross Price]))  , 0)

Esteemed Contributor

## Re: Current sales & previous sales calculation

Hi,

you can try with set analysis for best performance:

Create two variables:

vStart= start date

vEnd= end date

Sum({<[Process Date Time]= {">=\$(=vStart)<=\$(=vEnd)"}>} [Item Gross Price])

New Contributor

## Re: Current sales & previous sales calculation

I don't have separate start date and end date column, i have only only date range column(Procees date time)'

In that case how can i create variable ??

New Contributor

## Re: Current sales & previous sales calculation

I don't have separate start date and end date column, i have only only date range column(Procees date time)'

In that case how can i create variable ??

New Contributor

## Re: Current sales & previous sales calculation

VMINDATE=MIN(DATE(PRROCESS DATE TIME),'DD/MM/YYYY'))

VMAXDATE=MAX(DATE(PRROCESS DATE TIME),'DD/MM/YYYY'))

Esteemed Contributor

## Re: Current sales & previous sales calculation

You can User an input field to set your Min and Max variables.

Honored Contributor III

## Re: Current sales & previous sales calculation

Create like this

vMinDate  =MIN(DATE(PRROCESS DATE TIME),'DD/MM/YYYY'))

vMaxDate =MAX(DATE(PRROCESS DATE TIME),'DD/MM/YYYY'))

and use it