Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Announcements
QlikWorld 2020: Join us May 11 - 14, 2020 in Phoenix, AZ. Register early and save $400. Learn More
Highlighted
abhijit79008
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.

7 Replies
prma7799
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)

YoussefBelloum
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])

abhijit79008
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 ??

abhijit79008
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 ??

abhijit79008
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'))

YoussefBelloum
Esteemed Contributor

Re: Current sales & previous sales calculation

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

Chart type.png

prma7799
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