Skip to main content
Announcements
Global Transformation Awards submissions are open! SUBMIT YOUR STORY
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Compare total for year selected to previous year

I'm trying to show two different totals based on the year that the user selects (selected year and previous year). So if the user selects '2009' as the Year, then I want to show totals for both 2009 and 2008. Please advise.

Thanks,

Kevin

3 Replies
Not applicable
Author

If the user selects one year, then this expression will give you that year:

=ONLY(YearField)


Then you can use Set Analysis and a dollar sign expansion:

Sum({<YearField={$(=ONLY(YearField))}>} Sales)


For the previous year, use:

Sum({<YearField={$(=ONLY(YearField)-1)}>} Sales)


To combine them:

Sum({<YearField={$(=ONLY(YearField)), $(=ONLY(YearField)-1)}>} Sales)


I haven't tested that last one, but it seems like it should work.

Not applicable
Author

Can you draw a table of what you want to do or post an example

Nimish

Not applicable
Author

Use NMiller's first expression <blockquote><pre> Sum({<YearField={$(=ONLY(YearField))}>} Sales)
for an expression and
Sum({<YearField={$(=ONLY(YearField)-1)}>} Sales)
for another. You can easily more for showing even more previous year. Just replace '-1' with '-2', '-3', etc.