Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Sum function on load script

Hi guys,

         I have this script:

tmp:

Crosstable(category, value, 2)

LOAD startDate,

          endDate,

          categoryA

          categoryB

          categoryC

FROM ...

Outputs:

LOAD startDate,

          endDate,

          category,

          sum(value) as Total

FROM ...

Group by category

The first script (tmp) works and create the table.

The second script (Outputs) trowh an exception, invalid expression.

I don't understand why?

Please help me.

Thanks.

1 Solution

Accepted Solutions
rubenmarin

Hi Andrea, the group clause should have all field outside an agregation function:

Outputs:

LOAD startDate,

          endDate,

          category,

          sum(value) as Total

FROM ...

Group by startDate, endDate, category;

Or something like:

Outputs:

LOAD Min(startDate) as startDate,

          Max(endDate) as endDate,

          category,

          sum(value) as Total

FROM ...

Group by category

View solution in original post

3 Replies
rubenmarin

Hi Andrea, the group clause should have all field outside an agregation function:

Outputs:

LOAD startDate,

          endDate,

          category,

          sum(value) as Total

FROM ...

Group by startDate, endDate, category;

Or something like:

Outputs:

LOAD Min(startDate) as startDate,

          Max(endDate) as endDate,

          category,

          sum(value) as Total

FROM ...

Group by category

Anonymous
Not applicable
Author

I've used the first solution and it works very good.

Thanks

jyothish8807
Master II
Master II

Hi Andrea,

Try like this:

tmp:

Crosstable(category, value, 2)

LOAD startDate,

          endDate,

          categoryA

          categoryB

          categoryC

FROM ...

Outputs:

LOAD startDate,

          endDate,

          category,

          sum(value) as Total

FROM ...

Group by category,startDate,endDate;


Your all the fields with in with table apart from the aggregated filed should be in group by.


Br,

KC

Best Regards,
KC