Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
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
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;
You forgot to add other fields in Group by clause. That's why it is throwing error.
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
Thanks I am able to avoid synthetic by using join.