Skip to main content
Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Set Analysis - Ignore all selections but NOT year and Months

I have a chart where I want to ignore all selections but consider the Year (or Years) selected and the Month (or Months) selected.

I know the 1 tells Set Analysis to ignore selections. That part is working.

I know Only(Year) will make Set Analysis to consider only the selected Year. The same if I use Month. However, Only function works only if one single value is selected. in my chart, users can select none, one or many years or months. So, Max function will also not work.

Show can I do in this case?

7 Replies
Not applicable
Author

If my understanding is correct I think you can do something like below


count({<YEAR=Max(Year) ,Month=Max(Month),Dimension1= ,Dimension2=>} GROUP )



Not applicable
Author

Thanks for your help, but that is not what I want.

As I said, I do not want to get the maximum possible Year or Month because the user can select more than one month. For example, if Jan, Feb and Mar are selected, the Max function will consider only Mar, because is the highest month. I want to consider them all.

Not applicable
Author

Then you dont pass the month in the expresion then. Do some like below


count({<YEAR=Max(Year) ,Dimension1= ,Dimension2=>} GROUP )


Not applicable
Author

I know what you're saying. Instead of using 1 to exclude all selections, clean each one of them. I'd like to avoid that because the application has more than 30 different fields users can select, so the expression will be 2 big and 2 ugly.

Not applicable
Author

Are your Years and Months numeric values? If so, it is a bit easier.

Numeric:

Sum({1<Year={$(=GetFieldSelections(Year, ','))}>} Sales)


String:

Sum({1<Month={'$(=GetFieldSelections(Month, Chr(39) & Chr(44) & Chr(39)))'}>} Sales)


The String one is more difficult, because you need each value in the element set to be surrounded by quotes [Chr(39)] and have a comma in between [Chr(44)]. If you omit that part and just use the numeric example, you end up with quotes around the whole list, not each individual element.

I think there may be a way to reference a field's values directly, but I couldn't get it to work with the few I tried. You can combine the two if needed:

Sum({1<Month={'$(=GetFieldSelections(Month, Chr(39) & Chr(44) & Chr(39)))'},
Year={$(=GetFieldSelections(Year, ','))}>} Sales)


Not applicable
Author

My Year is numeric, my Month also because I am using Dual to make it string and number at the same time.

Your idea works perfectly if I have year(s) and month(s) selected but it does not work if I have no year or no month selected. I understand why and I am trying to fix it.

Not applicable
Author

Yes, with no selections it doesn't work. Something like:

$(=If(GetSelectedCount(Year)>0,GetFieldSelections(Year, ','), '*')


For the string, you need to replace '*' with Chr(39) & Chr(42) & Chr(39), since you can't embed the quotes.