Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Date minus one year in table

Hi Experts

I have the following problem:

I creadted a variable "VDateminus1year" with the the current date one year ago.

In a table chart I have the following code: Sum ({<Jahr={$(VaktJahr)}>} ([Rohertrag_aktJ])) giving me the sum of earnings in the current year.

Is it possible to change this code to sum up all earnings last year up to today one year ago, using my variable?

Thank you for your help!

Jan

1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Yes, it is possible. Create variable first and then try the expression below.

=sum({<Date={">=$(vStartPrevYTD)<=$(vEndPrevYTD)"}>}[Rohertrag_aktJ])

Variables:

vStartPrevYTD:=addyears(YearStart(Date ),-1)

vEndPrevYTD:=addyears(max(Date),-1)

View solution in original post

7 Replies
Anonymous
Not applicable
Author

try  sum({<Jahr={=$(VaktJahr)-1},MyDatefield={<=$(CDateminus1year)}>}Rohertrag_aktJ

first paramter filters the previous year, while second paramter filters from beginning of previous year upto

today - 1 year


Anonymous
Not applicable
Author

Yes, it is possible. Create variable first and then try the expression below.

=sum({<Date={">=$(vStartPrevYTD)<=$(vEndPrevYTD)"}>}[Rohertrag_aktJ])

Variables:

vStartPrevYTD:=addyears(YearStart(Date ),-1)

vEndPrevYTD:=addyears(max(Date),-1)

Not applicable
Author

Hi Rudolf

I tried the following: Sum ({<Audtragsdatum_aktJ={$(VDateminus1year)}>} ([Rohertrag_aktJ]))

But that only eaquals the date. How do I set the condition < my date in the variable?

Best

Jan

Anonymous
Not applicable
Author

try

{<=$(VDateminus1year)}

Not applicable
Author

then ([Rohertrag_aktJ])) has a red line undeneath. thus does not work...

Anonymous
Not applicable
Author

I send you an example of my current project, which works

sum

({<AuswahlMonat=,AuswahlJahr=,Berichtsdatum={'>=$(=$(vStartDatum)<=(=$(vEndDatum)))'}>}Kapitalstand)


Not applicable
Author

Thanks you gave me a clue to a solution.