Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
bryan_21
Contributor III
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)
2 Solutions

Accepted Solutions
simospa
Partner - Specialist
Partner - Specialist

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

simospa_0-1707211855620.png

Does this solution work for you?

S.

 

View solution in original post

PrashantSangle

Try below

PrashantSangle_0-1707213138064.png

 

Result

 

PrashantSangle_1-1707213199350.png

 

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 🙂

View solution in original post

6 Replies
simospa
Partner - Specialist
Partner - Specialist

Hi,

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

S.

bryan_21
Contributor III
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.

bryan_21_0-1707209108460.png

 

simospa
Partner - Specialist
Partner - Specialist

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

simospa_0-1707211855620.png

Does this solution work for you?

S.

 

bryan_21
Contributor III
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?

PrashantSangle

Try below

PrashantSangle_0-1707213138064.png

 

Result

 

PrashantSangle_1-1707213199350.png

 

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

Thank you! Tried using and actually works.