Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
baarathi
Creator III
Creator III

I want to compare records of the currently selected year and 2 years of its past?

I want to compare records of the currently selected year and 2 years of its past?

For example, if I currently select 1998 as the year it should compare 1996 year's subtotal with the 1998 year's subtotal, in bar chart

=sum({$<OrderYear=getfieldselections(OrderYear)-2>}Subtotal)

I'm getting the desired result, with the above statement.Can you help me the above statement and correct if it has some mistake.Thanks in advance

1 Solution

Accepted Solutions
devarasu07
Master II
Master II

Hi,

try this way,

sum( {$<OrderYear={"$(=max(OrderYear)-2)"}>} Sales)

Capture.JPG

View solution in original post

10 Replies
YoussefBelloum
Champion
Champion

Hi,

use this instead:

=sum({$<OrderYear={$(=getfieldselections(OrderYear)-2)} >} Subtotal)


Or

=sum({$<OrderYear={$(=Max(OrderYear)-2)} >} Subtotal==> to always have a result displayed even if you select nothing on the OrderYear

hope it helps



devarasu07
Master II
Master II

Hi,

try this way,

sum( {$<OrderYear={"$(=max(OrderYear)-2)"}>} Sales)

Capture.JPG

arvind_patil
Partner - Specialist III
Partner - Specialist III

Hi Baarathi,

Your above statement is correct if you want on another way like below:


=sum({$<OrderYear={'(=AddYears(max([OrderYear]),-2))'}>}Subtotal)


Thanks,

Arvind Patil

baarathi
Creator III
Creator III
Author

Thanks a lot sir for the solution,But this expression "$(=max(OrderYear)-2)"given within double quotes,can you explain me this part?

baarathi
Creator III
Creator III
Author

Thanks a lot sir.Can you explain this part '(=AddYears(max([OrderYear]),-2))' the contents given within single quotes will be treated as values right? can you please explain this part of your statement alone?

baarathi
Creator III
Creator III
Author

Thanks a lot sir.

devarasu07
Master II
Master II

Hi,

Single/double defined like this way

String value : Required single quotes within the element set

numeric value : do not require single or double quotes

expression or search : require double quotes

for more details check here,

A Primer on Set Analysis

Capture.JPG

arvind_patil
Partner - Specialist III
Partner - Specialist III

Hi Bhaarthi,

1. AddYears function add number of years into your current date so if you add negative years (-2) so it minus from current date.

2. Single quotes treated as value.

Please add below code into text  box you will get idea:

=AddYears(Max(Today()),-2)


Thanks,

Arvind Patil

baarathi
Creator III
Creator III
Author

Thank your sir.It was very much helpful