Skip to main content
Announcements
July 15, NEW Customer Portal: Initial launch will improve how you submit Support Cases. IMPORTANT DETAILS
cancel
Showing results for 
Search instead for 
Did you mean: 
Solomoons
Contributor III
Contributor III

Please Help Me with this code error when using 'group by' in script

Hi All,

The "invalid Expression" Error is popped out when I try to run the code below:

Solomoons_0-1671635657252.png

I want to do some operation in the 'if' function and try to use 'month(max(Fdate))' to get the biggest month shown in Fiscal year 23. But when I try to connect the strings, the error occurs. So I wonder what should I do to eliminate the error. Or could I use a variable in the code and replace the "Month(Max(FDate))" wit it? 

 

For your reference, the data and the final results I want would be like this:

Solomoons_1-1671636036773.png

 

 Any help it would be really appreciate!!

Labels (5)
7 Replies
SerhanKaraer
Creator III
Creator III

Hello Solomoons,

The fields in the GROUP part by must match the fields in the LOAD part. We can not the see all the fields in your MDOT table, but it is sure that Fyear has to be stated in the GROUP part.

I hope it solves your problem.

Solomoons
Contributor III
Contributor III
Author

Thank you so much! I have solved the problem😀

Solomoons
Contributor III
Contributor III
Author

Hello SerhanKaraer,

After I loaded the data and drew a graph in sheet,  the dimension 'FY' shows like below:

Solomoons_0-1671671631959.png

Do you know why it looks like this way? And what should I do to make the dimension be "2019,2020,2021,2022,2023P3" ?

SerhanKaraer
Creator III
Creator III

Maybe you should omit FDate in GROUP BY part, just put Fyear. It seems that you calculate max in a more granular level than a year. If it does not solve , you must provide either data model or fields of MDOT table to be able to help me solid comments.

Solomoons
Contributor III
Contributor III
Author

Hello,

I have tried to omit the 'FDate' field in GROUP BY part, but it occurs the 'Invalid Expression' error. 

And here is the whole script I have written, and I'd appreciate it if you could help me to find the problems and give me some comments~ Thanks!

Solomoons_0-1671760260684.png

Solomoons_1-1671760305396.png

Solomoons_2-1671760334053.png

 

 

 

anat
Master
Master

use only required fields in load statement ,

load fyear,fdate,if(.........) resident table group by fyear,fdate...

Solomoons
Contributor III
Contributor III
Author

Hello Anat,

I have tried what you said, and make a test sample below, but result is still not what I want, and it seems the month(max(Fdate)) didn't work. 

Solomoons_0-1671779036227.png

the result is shown here: I want the FY to be (2022,2023P7) but it gives me (2022,2023P4, 2023P6, 2023P7)

Solomoons_1-1671779079147.png

I'd appreciate it if you could give me more comments