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

Announcements
Qlik Connect 2026 Agenda Now Available: Explore Sessions
cancel
Showing results for 
Search instead for 
Did you mean: 
ben0109
Contributor III
Contributor III

Group by

Hi

I have a table that I want to use Group By, but cannot seem to figure myself out here.

My load script:
Load
[Date from],
[Date to],
Supplier,
[Contract number],
Code
From myTable;

When I add the Group By clause after the 'From' section, I get the error that something is wrong near 'group'.

I want to group by Supplier and Contract number.

Any ideas how to fix this?

Labels (2)
1 Solution

Accepted Solutions
QFabian
MVP
MVP

Hi @ben0109 , 

You have to check what do you want to group as aggregation, for example count Codes, or sum anything else.

Then the fields you want to group by , they have to be in yor load , you can try something like this :

 

TableA:
Load
[Date from],
[Date to],
Supplier,
[Contract number],
Code
From myTable;

//groping table

TableB:

Load

Supplier,
[Contract number],

count(Code)   as CodeQuantity

Resident TableA

group by 

Supplier,
[Contract number];

Greetings!! Fabián Quezada (QFabian)
did it work for you? give like and mark the solution as accepted.

View solution in original post

4 Replies
Anil_Babu_Samineni

I don't see why group by required. But you must use group by when you have aggregate functions. Syntax will be after table..

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
QFabian
MVP
MVP

Hi @ben0109 , 

You have to check what do you want to group as aggregation, for example count Codes, or sum anything else.

Then the fields you want to group by , they have to be in yor load , you can try something like this :

 

TableA:
Load
[Date from],
[Date to],
Supplier,
[Contract number],
Code
From myTable;

//groping table

TableB:

Load

Supplier,
[Contract number],

count(Code)   as CodeQuantity

Resident TableA

group by 

Supplier,
[Contract number];

Greetings!! Fabián Quezada (QFabian)
did it work for you? give like and mark the solution as accepted.
Vegar
MVP
MVP

As @QFabian and @Anil_Babu_Samineni  are writing or are you trying to get the sort order correct? If so then use order by instead of group by. 

Order by Supplier, Contract      will load your data in the order of the two fields in descending order. 

ben0109
Contributor III
Contributor III
Author

Thanks! The pink part in your answer made it clear.