Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Can someone correct the code please

Table3:

LOAD SKU#, [Sum of Units packed in recent 30 days],(TODAY() - MinDate30) AS [Diff. of days in 30 days time frame];

LOAD SKU#,Sum([Units Packed 30]) as [Sum of Units packed in recent 30 days], Min(FilteredDate30) AS MinDate30

GROUP BY SKU#;

LOAD SKU#, [Units Packed] AS [Units Packed 30],[Ship Date] AS FilteredDate30

RESIDENT Table1

WHERE [Ship Date] > TODAY()-31;

Table4:

LOAD SKU#, [Sum of Units packed in recent 30 days],[Diff. of days in 30 days time frame],([Sum of Units packed in recent 30 days]/[Diff. of days in 30 days time frame]) as [30 day velocity]

GROUP BY SKU#;

LOAD SKU#, [Sum of Units packed in recent 30 days], [Diff. of days in 30 days time frame]

Resident Table3

1 Solution

Accepted Solutions
jonathandienst
Partner - Champion III
Partner - Champion III

I dont know about correcting it, but all that code can be simplified to:

LOAD SKU#,

  Sum([Units Packed]) as [Sum of Units packed in recent 30 days],

  (TODAY() -  Min([Ship Date])) AS [Diff. of days in 30 days time frame],

  (Sum([Units Packed])/(TODAY() -  Min([Ship Date]))) as [30 day velocity]

RESIDENT Table1

WHERE [Ship Date] > TODAY()-31

GROUP BY SKU#;

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein

View solution in original post

4 Replies
Not applicable
Author

its throwing an error: Aggr() function needs group by clause;

PrashantSangle

Hi,

When you use aggregated function in script you need to use group by clause and group by non aggregated field.

For example

Data:
LOAD * INLINE [
    id, Country, Sales
    1, India, 5000
    2, UK, 1000
    4, USA, 6000
    3, Aus, 5200
];

NoConcatenate
data1:
load id,Country,Sum(Sales) as sumSales Resident Data Group by id,Country;

DROP Table Data

Regards

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
jonathandienst
Partner - Champion III
Partner - Champion III

I dont know about correcting it, but all that code can be simplified to:

LOAD SKU#,

  Sum([Units Packed]) as [Sum of Units packed in recent 30 days],

  (TODAY() -  Min([Ship Date])) AS [Diff. of days in 30 days time frame],

  (Sum([Units Packed])/(TODAY() -  Min([Ship Date]))) as [30 day velocity]

RESIDENT Table1

WHERE [Ship Date] > TODAY()-31

GROUP BY SKU#;

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Not applicable
Author

It worked. Thanq Jonathan