Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

help Needed

hi,

   Im having a problem in script to find ,

   Orders within last 30 Days,

   Orders between 31-60 days,

    

LOAD OrderID,

     CustomerID,

     EmployeeID,

     OrderDate,

     Year(OrderDate) as Year,

     Month(OrderDate) as  Month,

     Week(OrderDate) as Week,

     If( (Today() - OrderDate)<31, ORDER) as Last30DaysOrded,

     If( (Today() - OrderDate)>30  AND (Today() - OrderDate)>61,ORDER) as 31to60DayOrded,   

     RequiredDate,

     ShippedDate,

     ShipVia,

     Freight,

     ShipName,

     ShipAddress,

     ShipCity,

     ShipRegion,

     ShipPostalCode,

     ShipCountry

                     This is my script , can anyone help for me .

4 Replies
alexandros17
Partner - Champion III
Partner - Champion III

Probably dates have not the same format, try with date(Today(),'dd/MM/yyyy'), date(OrderDate,'dd/MM/yyyy')

Anonymous
Not applicable
Author

LOAD OrderID,

     CustomerID,

     EmployeeID,

     OrderDate,

     Year(OrderDate) as Year,

     Month(OrderDate) as  Month,

     Week(OrderDate) as Week,

     If( (Today() - OrderDate)<31, ORDER) as Last30DaysOrded,

     If( (Today() - OrderDate)>30  AND (Today() - OrderDate) < 61,ORDER) as 31to60DayOrded,  

     RequiredDate,

     ShippedDate,

     ShipVia,

     Freight,

     ShipName,

     ShipAddress,

     ShipCity,

     ShipRegion,

     ShipPostalCode,

     ShipCountry

Not applicable
Author

Diego,

       Still not Working .

Sokkorn
Master
Master

binodkoirala wrote:

     If( (Today() - OrderDate)<31, ORDER) as Last30DaysOrded,

     If( (Today() - OrderDate)>30  AND (Today() - OrderDate)>61,ORDER) as 31to60DayOrded,

You want to find order base on period. Look at your If() statement; found something wrong. See you return "ORDER" with both If() statement; that is logic error.

Here is my suggestion is create a flag for each period, something like:

Load

...

ORDER, //Assum this field is your order amount

If(Today()-OrderDate<31, '0-30') AS Last30DaysOrded,

If(Today()-OrderDate)<61,'31-60') AS 31to60DayOrded,

...

Then if you want to sum order in last 30 day, we can use =Sum({$<Last30DaysOrded = {'0-30'}>} ORDER)

Regards,

Sokkorn