Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
enfodavid
Partner - Contributor III
Partner - Contributor III

Calculation condition possible values, multiple values

I want to be able to easily add and subtract fields from possible values in a calculation condition. If there is any other combination I don't want it to be true.  In the example below I get it to work with two values; Value1 and Value2. 

if(concat(distinct [Field1], ', ') = 'Value1' or
concat(distinct[Field1], ', ') ='Value2' or
concat(distinct[Field1], ', ') ='Value1, Value2',1,0)

I want to be able to do it easily for more than 2 values. For each value added the code would get longer, the next example is with a third added value;

if(concat(distinct [Field1], ', ') = 'Value1' or
concat(distinct[Field1], ', ') ='Value2' or
concat(distinct[Field1], ', ') ='Value3' or
concat(distinct[Field1], ', ') ='Value1, Value2' or
concat(distinct[Field1], ', ') ='Value1, Value3' or
concat(distinct[Field1], ', ') ='Value2, Value3' or
concat(distinct[Field1], ', ') ='Value1, Value2, Value3',1,0)

So the code will get exponentially longer and longer, even though I just want another field value added. Has anyone done anything similar without the hassle of longer and longer code?

Labels (4)
14 Replies
enfodavid
Partner - Contributor III
Partner - Contributor III
Author

This would have the same built in mistake where if something has Value5 as well as Value1 it would get a Flag

sunny_talwar

How? Value1 will have Flag 1, and Value5 will have Flag 0... and Min(Flag) = 0?

Vegar
MVP
MVP

What if you do a comparison like the one I've done below? In my quick test it seems to work as desired.

if(
 Concat(DISTINCT Field1, ', ') 
  = 
  Concat({< Field1 *= {'Value1', 'Value2'}>}DISTINCT Field1, ', ')
 ,1,0)

 I've attached my test qvw app

enfodavid
Partner - Contributor III
Partner - Contributor III
Author

Oh, I didn't see the last part. That might actually be it!

enfodavid
Partner - Contributor III
Partner - Contributor III
Author

Thank you for your time and help!