Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I'm looking for the "best" expression to test if the current possibles of a field contains one or more values. For example:
if( Region contains 'US",
By best, I mean fast, compact easy to write, and no redundancy. In the past (pre Set Analysis) I've used
sum(if(Region='US',1))>0
With Set Analysis I'm using:
count({$*<Region={US}>}DISTINCT Region)>0
but I don't like having to type "Region" twice. I know I've seen some more clever forms posted here. Anyone have a better suggestion?
Thanks,
Rob
Hi Rob,
You can arrive a Flag in your script with 1 for Region US and just use this expression
Data:
LOAD
*,
If(Region = 'US', 1, 0) AS Flag
FROM DataSource;
=Sum(Flag) > 0
Regards,
Jagan.
Hi Jagan,
Thanks for the suggestion, but script is not flexible enough. I'm looking for a chart expression.
-Rob
I will do it like this...
count({<Region={'US'}>} DISTINCT Region)
Note that US must be into '' becuase is not a number.
this expression will count how many DISTINCT regions will have registres which region is us....
count(DISTINCT Region)
will show you how many regions are by the dimension you have exposed...
Maybe this could be an alternative:
max(match(Region, 'US'))>0
I like that one Jerem. I'll test the performance on some large sets.
Edit: I tested on some very large datasets and it performs well!
-Rob
Hi Rob,
Check this, this is more better than using Match, because we are using Set Analysis
=MaxString({<Region={'US'}>} Region) > 0
Regards,
Jagan.