Skip to main content
Announcements
Global Transformation Awards! Applications are now open. Submit Entry
cancel
Showing results for 
Search instead for 
Did you mean: 
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Set Analysis - Qualifying global set with current selections

Greetings set analysis gurus. Consider the following table:

Dept, Account, Period, Value
D1, A1, 1, 100
D2, A2, 1, 200
D2, A2, 2, 300
D2, A3, 2, 350
D3, A2, 2, 400
D3, A3, 2, 500
D3, A4, 2, 600

I select Period 1 and Dept D2 as my current selections. I want to display the Values from the selected period (1) and the next period (2). I want the chart to only show accounts that are linked to the selections -- A2 & A3 in this case. Using the following for the Period 2 expression:

=sum( {1<Period = {$(#=Only(Period)+1)}>} Value )

I get Account A4, which is not part of the selection.

Account Period 1 Period 2
A2200700
A30850
A40600


I can modify the expression to include the Dept, but this only works when I select a single Dept.

=sum( {1<Period = {$(#=Only(Period)+1)}, Dept = {$(=Only(Dept))}>} Value )

Account Period 1 Period 2
A2200300
A30350


What expression would I use for Period 2 if I to filter with multiple selected Dept, for example, both D1 & D2 selected. In that case I would expect to see accounts A1 & A2 with correct values.

An example qvvw is attached.

Thanks,
-Rob

1 Solution

Accepted Solutions
Not applicable

Hi Rob,

Maybe my solution works for you.

I think there would be a possible optimization in the variable calculation, but I'm not sure:


=if(getexcludedcount(Dept) > 0,concat('"' & Dept & '"',','))


Regards.

View solution in original post

8 Replies
Not applicable

Hi Rob,

Maybe my solution works for you.

I think there would be a possible optimization in the variable calculation, but I'm not sure:


=if(getexcludedcount(Dept) > 0,concat('"' & Dept & '"',','))


Regards.

jonathandienst
Partner - Champion III
Partner - Champion III

Rob

You got A4 from your first expression because of the {1< set selector which overrides all selections (including your Department selection).

If I've understood you correctly, Just remove the 1, so the expression reads:

=sum({<Period = {$(#=Only(Period)+1)}>} Value)

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP
Author

Thanks Miguel! Your solution works great.

-Rob

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP
Author


Jonathan Dienst wrote:If I've understood you correctly, Just remove the 1, so the expression reads:


I need the 1 selector to get data from the other period -- which is not selected.

-Rob

Not applicable

Hi Rob,

Jonathans suggestion will work. You wont need the {1} for the second period as period is a dimension in the chart. I have just tried it and it looks correct.

Kind Regards,

Footsie

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP
Author

I'm not seeing how it would work without the "1" selector. Can you post a working qvw based on my original example?

Thanks,

Rob

johnw
Champion III
Champion III


Rob Wunderlich wrote:I'm not seeing how it would work without the "1" selector. Can you post a working qvw based on my original example?


I'm a bit confused about the final result that you want, but since you verified Miguel's answer, I guess you want the table that he shows when no departments are selected? If so, this returns the same answer using only set analysis and no variables:

sum({<Dept=P(),Period={$(=Only(Period)+1)}>} Value)

Dept=P() says to "select" only the possible departments based on the other selections. So you'll only get period 1 departments, D1 and D2. Then we override the Period selection, adding 1 to it. The "1" set shouldn't be used as we don't want to override ALL selections, only the period selection. See attached. Hopefully I've understood what you're looking for.

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP
Author

Thanks John. That's a cleaner solution. I like it and it gives me the result I'm after.

-Rob