Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Set Analysis Max Year, Month

Hello,

I'm trying to do something that seems relatively simple but i cannot get it to work. I want to calculate the sum of a value only for the maximum year and month of the current selection. This is the expression i'm using,

sum({$<YEAR = {$(=max(YEAR))}, MONTH = {$(=max(MONTH))}>} Stock_Value_CY)

I;ve broken the expression in its compnenets and although the expression for max year works, the expression for max month doesn't.

Anybody can see what i;m doing wrong?

1 Solution

Accepted Solutions
Not applicable
Author

create an extra field in your script as

num(Month(Yourdatefield)) as Month#,

and reload the application and write your expression as

sum({$<YEAR = {$(=max(YEAR))}, Month# = {$(=max(Month#))}>} Stock_Value_CY)

hope it will work

View solution in original post

14 Replies
PrashantSangle

Hi,

Try in ""

like

sum({$<YEAR = {"$(=max(YEAR))"}, MONTH = {"$(=max(MONTH))"}>} Stock_Value_CY)

Regards

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
MK_QSL
MVP
MVP

Can you share your sample apps please?

jyothish8807
Master II
Master II

Hi Petrovic,

Your expression looks good , i think some issue with month field.Can you please share your app?

Try =max(MONTH) in a textbox and see what output you are getting?

Regards

KC

Best Regards,
KC
Not applicable
Author

I've already tried this syntax, it doesn't work.

Not applicable
Author

I've done this and it gives me back the value i want. it is numeric, integer btw.

I've also tried making the calculations into variables and use the variables but it still doesn;t work. A set analysis expression using the year variable works but the month doesn;t.

Not applicable
Author

I can't upload the app because I'm working on a document taken from the customer which is too big to upload. I do not have a smaller data set.

Not applicable
Author

try this

i guess u made field mistakes

sum({$<YEAR = {$(=max(YEAR))}, MONTH = {$(=max(MONTH))}>} Stock_Value_CY)

do u have the field called month in capital letters?

ashwanin
Specialist
Specialist

Hi Vasilis,

=max(year) provide you 2014 , while =max(month) provide you ' - '

Please add the field name from where you are taking the month

e,g =max(month(today()))

Not applicable
Author

These 2 fields are in capital letters and i've tried pasting the actual field names. The result is the same.