Skip to main content
Announcements
See why Qlik is a Leader in the 2024 Gartner® Magic Quadrant™ for Analytics & BI Platforms. Download Now
cancel
Showing results for 
Search instead for 
Did you mean: 
FisherShi
Contributor II
Contributor II

keep string in dollar sign expansion expression

Hi, I'm working a expression to calculate the spend amount of last month, the last month is "2021-05".

And thus the expression i used is: sum({1<[Load Month] = {$(=maxstring([Load Month]))}>} [Total Cost Gross]).

I cannot get any result, it seems the return of $(=max([Load Month])) is 2016, the string "2021-05" is got calculated.

I'm thinking to change the data structure for the Load Month in script. I believe there's alternative way to fix it by adding some letter in the expression to keep the string not be calculated, anyone can help? thanks

Fisher

Labels (3)
1 Solution

Accepted Solutions
MayilVahanan

Hi @FisherShi 

If load month is "2021-05" as string, you can make it as "Date" like below

=MakeDate(Left('2021-05', 4), Right('2021-05', 2)) gives 2021-05-01 

In Load script,  

Load *, MakeDate(Left(LoadMonth, 4), Right(LoadMonth, 2)) as LoadMonth from yoursource;

Then in front end,

Sum({1<[Load Month] = {'$(=Date(max([Load Month])))'}>} [Total Cost Gross])

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.

View solution in original post

2 Replies
MayilVahanan

Hi @FisherShi 

If load month is "2021-05" as string, you can make it as "Date" like below

=MakeDate(Left('2021-05', 4), Right('2021-05', 2)) gives 2021-05-01 

In Load script,  

Load *, MakeDate(Left(LoadMonth, 4), Right(LoadMonth, 2)) as LoadMonth from yoursource;

Then in front end,

Sum({1<[Load Month] = {'$(=Date(max([Load Month])))'}>} [Total Cost Gross])

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
FisherShi
Contributor II
Contributor II
Author

it works, thank you Mayil.

Regards,

Fisher