Announcements
cancel
Showing results for
Did you mean:
Contributor III

## Get current date selection versus last year

How to get the date from previous year and use in a measure? I have a date picker which date is from this year, when I select atleast 1 date (ex. Feb 1, 2024 then I should get the date from last year which is Feb 1, 2023) but how about if I select more than 1 date, how can I get the value of that from the date last year? I'm using GetFieldSelections and I can get the selected date value from this year. Ex. 2/2/2024, 2/3/2024

Labels (3)

• ### Variables

2 Solutions

Accepted Solutions
Partner - Specialist

If I figure out what you want, you could try with AddYears function with -1 as argument:

Does this solution work for you?

S.

Try below

Result

Regards,

Prashant Sangle

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 🙂
6 Replies
Partner - Specialist

Hi,

can you please send a sample of the desired situation? Which kind of formula do you want to use?

S.

Contributor III
Author

It should be like this. If I select multiple dates then I should get the same date from previous year so that I can get the growth based on the selected date.

Sample selected date: Feb 1, 2024 and Feb 2, 2024

The value in function GetFieldSelections is 2/1/2024, 2/2/2024 (contains comma). How can I get the date from last year based on the selected current date?

Attached sample below.

Partner - Specialist

If I figure out what you want, you could try with AddYears function with -1 as argument:

Does this solution work for you?

S.

Contributor III
Author

Yes, thank you! This could work but I need to put the AddYears value in a measure. Like Sum(This Year) Sales - Sum(AddYears value) Sales. any better approach?

Try below

Result

Regards,

Prashant Sangle

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 🙂
Contributor III
Author

Thank you! Tried using and actually works.