Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Is it possible to set a field equal to another field using set analysis AND have it apply that logic over a dimension?
I have a dimension called Severity with values of 0 and 1. So my graph is split into a 0 and a 1; I want to show the number of consumers that are 0 for ADL Bathing and how many are 1 for ADL Bating.
I am trying to write this
Sum(If([ADL Bathing] = Severity, _ConsumerCounter)) using Set analysis
The closest thing I can come up with is
sum({<ADL Bathing]=P([Severity])>} _ConsumerCounter)
I'm only using the P function (which I dont want to) becuse that's the only way I can get the expression to say OK. The P function is actually just gruoping all consumers with either a 0 or a 1.
Anyway to set a field equal to another in set analysis?
Use pick() instead of the if() statement (which only allows for true / false branching):
=pick( Severity+1,
sum({<[ADL Bathing] = {0} >} _ConsumerCounter),
sum({<[ADL Bathing] = {1} >} _ConsumerCounter),
sum({<[ADL Bathing] = {2} >} _ConsumerCounter),
sum({<[ADL Bathing] = {3} >} _ConsumerCounter)
)
A set expression is evaluated once per chart, not considering your dimension value.
So either stick with your first version sum(if(...)) or try maybe
if( Severity,
sum({<[ADL Bathing] = {1} >} _ConsumerCounter),
sum({<[ADL Bathing] = {0} >} _ConsumerCounter)
)
Hi Swuehl. This exprssion is working great. Thank you. The only thing is I am trying to expand this to include th eother values. So my Severity is actually 0 through 3 and when I try this
if( Severity,
sum({<[ADL Bathing] = {3} >} _ConsumerCounter),
sum({<[ADL Bathing] = {2} >} _ConsumerCounter),
sum({<[ADL Bathing] = {1} >} _ConsumerCounter),
sum({<[ADL Bathing] = {0} >} _ConsumerCounter)
)
It doesn't work. Any idea?
Use pick() instead of the if() statement (which only allows for true / false branching):
=pick( Severity+1,
sum({<[ADL Bathing] = {0} >} _ConsumerCounter),
sum({<[ADL Bathing] = {1} >} _ConsumerCounter),
sum({<[ADL Bathing] = {2} >} _ConsumerCounter),
sum({<[ADL Bathing] = {3} >} _ConsumerCounter)
)
This worked perfectly. Thank you so much. Out of curiousity, what does the +1 do?
Adding 1 to the value of Severity.
So a Severity of 0 will execute the first expression in the list, a Severity of 1 the second, etc.
Is it possible not to repeat the sum so many times?
What would you do when you have more than just 4 possible values?