Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I have YTD setup on my app, which works great. It uses flags and set analysis to work exactly how i planned it. however, the end user expect CY to be the year selected on the year list box. So if they select 2008 in the list box, then the current year is 2008 and previous year is 2007.
I'm not sure where to begin on that functionality and was curious if anybody had any thoughts? My current code for cy is sum({$<[Year]={2009}>}Dollars*CurrentYear_Flag)
Thanks,
If there is only one year selected in the box, you can use ONLY():
sum({$<[Year]={$(=ONLY(Year))}>}Dollars)That would get you the sum for the selected year. For year prior to selected:
sum({$<[Year]={$(=ONLY(Year) - 1)}>}Dollars)I got rid of the CurrentYear_Flag, because I figured that was used for the real current year and you wouldn't want them for selection based.
If you allow multiple years to be selected or no year to be selected, the ONLY() function won't work.
Would it be possible that if no selections are made that it shows by default the current year as the current year?
If you replace ONLY with MAX, that may work. If no selection is made, it would return the maximum year you have, which I would expect to be the current year. If one selection is made, then it would return the same as ONLY. If multiple selections are made, then it would be the same as if only the max selected year is selected.
If not, you can probably get into creating a variable to store the Set Analysis:
vVar = if(GetSelectedCount(Year) = 1, "{<Year = {$(ONLY(Year))}>}")Then in your expression:
sum($(vVar) Dollars)
The first method seems like it should work for you, but if you want to get more complicated, then you probably need to go down the variable route. NOTE: This second suggestion is not sufficient to handle multiple selections. If you wanted to use the variable and multiple selections, you would need to handle the > 1 case.