Skip to main content
Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
cancel
Showing results for 
Search instead for 
Did you mean: 
saifuddin
Contributor III
Contributor III

Max function in Load Script without creating resident table

Hi Everyone, 

Just wondering can Max function be used in load script without creating a Resident Table

LOAD

ID,
grade,
date,
max(date) as NewDate

FROM ……..\SourceData.xlsx] (ooxml, embedded labels, table is Sheet1)

Group By ID;

This comes up as Invalid Expression. With resident table it works file. 

 

Thanks

Saif

 

 

2 Solutions

Accepted Solutions
saifuddin
Contributor III
Contributor III
Author

Hi Tko, 

Thanks for your response. That explain why I was getting invalid expression. The table I am trying to use Max Function, it has more than 25 fields. I guess it won't be ideal to use all these fields under Group By clause. 

 

I already used your solution 2,  which creates a synthetic as I am using more than 1 fields as Group By. Not a big fan of synthetic key.

Thanks

 

 

View solution in original post

ToniKautto
Employee
Employee

My example should not lead to synthetic key, as it only has one common key field.

If you has multiple key field, you could either join the result back to the base table or create a composite key in the base table and use that as the common key field.

View solution in original post

5 Replies
ToniKautto
Employee
Employee

Aggregation during load requires that you define how the aggregation is expected to be grouped. Meaning that you need to define over which dimensions you want the table to be aggregated over, which is done through GROUP BY.

Fields defined in the load statement must be aggregations or be included i GROUP BY. In your example the fields grade and date are not following this rule, and I expect that is why the reload fails.

The structure of your script really depends on what you are trying to accomplish. This could be one way to add an aggregated max value to your data model, in two separate tables associated over the ID field.

MyTable:
LOAD *
FROM ……..\SourceData.xlsx] (ooxml, embedded labels, table is Sheet1)

LOAD
ID,
max(date) as NewDate
Resident MyTable
Group By ID;

shiveshsingh
Master
Master

You forgot to add other fields in Group by clause. That's why it is throwing error.

saifuddin
Contributor III
Contributor III
Author

Hi Tko, 

Thanks for your response. That explain why I was getting invalid expression. The table I am trying to use Max Function, it has more than 25 fields. I guess it won't be ideal to use all these fields under Group By clause. 

 

I already used your solution 2,  which creates a synthetic as I am using more than 1 fields as Group By. Not a big fan of synthetic key.

Thanks

 

 

ToniKautto
Employee
Employee

My example should not lead to synthetic key, as it only has one common key field.

If you has multiple key field, you could either join the result back to the base table or create a composite key in the base table and use that as the common key field.
saifuddin
Contributor III
Contributor III
Author

Thanks I am able to avoid synthetic by using join.