Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

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
Master III
Master III

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
Champion
Champion

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

Anonymous
Not applicable
Author

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

Anonymous
Not applicable
Author

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

Anonymous
Not applicable
Author

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

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

YoussefBelloum
Champion
Champion

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

Chart type.png

prma7799
Master III
Master III

Create like this

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

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


and use it