Skip to main content
Announcements
Introducing a new Enhanced File Management feature in Qlik Cloud! GET THE DETAILS!
cancel
Showing results for 
Search instead for 
Did you mean: 
WriteCodeEveryDay
Contributor II
Contributor II

User defined date variable not working in sum expression year

I know this is just a syntax issue but I can't seem to find a clear explanation of how to do this. I just want to use the year expression to refine my sum value. I can put a hardcoded value like 2022 in and it works fine, like this:

Year = {2022},

But this doesn't work
Year = Year(vSelectionDateStart),

However if I display just this:

Year(vSelectionDateStart)

it gives me the year like I would expect.

Can someone please explain what I'm doing wrong and if you'd be so kind why?

 

Here's the complete block for reference:

sum({<
Year = {2022},

// Year = Year(vSelectionDateStart),

[Account.Account Number]={660}
>}

[Transactions.Amount With Sign]
)

 

Thanks!

Labels (1)
1 Solution

Accepted Solutions
WriteCodeEveryDay
Contributor II
Contributor II
Author

This was on the right track, I had to drop the second $ and parenthesis. 

This worked:

Year={$(=Year(vSelectionDateStart))},

 

Thanks for getting me headed in the right direction!

View solution in original post

4 Replies
Aurelien_Martinez
Partner - Specialist II
Partner - Specialist II

Hi,

 

You can try : 

 

Year={$(=Year($(vSelectionDateStart)))}

Help users find answers! Don't forget to mark a solution that worked for you!
brunobertels
Master
Master

Hi 

 

Try this 

sum({<
Year = {'$(vSelectionDateStart)'},

 

[Account.Account Number]={660}
>}

[Transactions.Amount With Sign]
)

WriteCodeEveryDay
Contributor II
Contributor II
Author

Unfortunately neither of these seem to work. I failed to explain the date format in the variable. It's 03/01/2022 to clarify.

Year = {'$(vSelectionDateStart)'},

The above doesn't seem to have the year function to strip that value out.

Year={$(=Year($(vSelectionDateStart)))},

In this everything in the braces goes gray like it's all being interpreted as a literal (I think, new to qlik).

Any other suggestions?

 

WriteCodeEveryDay
Contributor II
Contributor II
Author

This was on the right track, I had to drop the second $ and parenthesis. 

This worked:

Year={$(=Year(vSelectionDateStart))},

 

Thanks for getting me headed in the right direction!