Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
paolo_mapelli
Creator II
Creator II

Expression with boolean variable in set analysis

Good Morning,

I've a simple expression like this: Sum(if($(bCondition),Adults))

$(bCondition) is a boolean variable.


How can I "translate" it correctly in set analysis syntax ?

Thanks in advance.

Paolo.

1 Solution

Accepted Solutions
rahulpawarb
Specialist III
Specialist III

I 100% agree with Chanty! While loading the data create a flag field with definition of $(bCondition) i.e. 1 or 0; later you can consume it in set expression as Sum({<flag={1}>}Adults).


Regards!

Rahul Pawar

View solution in original post

13 Replies
agigliotti
Partner - Champion
Partner - Champion

how your bCondition variable looks like ?

Chanty4u
MVP
MVP

try with single quotes

Sum(if('$(bCondition)',Adults))

paolo_mapelli
Creator II
Creator II
Author

It's a (very complex) boolean expression, that I don't want to replicate with set analysis syntax...

paolo_mapelli
Creator II
Creator II
Author

That's not set analysis syntax...

Chanty4u
MVP
MVP

if you want to create set ,

create a flag for bCondition     value inside it and use that in frontend set analysis


agigliotti
Partner - Champion
Partner - Champion

i guess you can't.

why are you thinking to use set analysis ?

i think you should rewrite the boolean variable logic inside the script adding a new field, after you can use it in set analysis.

paolo_mapelli
Creator II
Creator II
Author

Because lot of people told me that "if" lacks on performance, so I'm evaluating how to convert these expressions with set analysis.


An alternative would be convert them and store expressions into variables, then use them.


Example: let's say $(bCondition) is something taking everything that current selection excludes, built with "if" and other script functions. In set analysis it's intended as {1-$}. <pseudo-syntax mode on> So: LET bCondition = "{1-$}". Then: sum(<$(bCondition)>Adults) </pseudo-syntax mode off>


But I don't think it's an available way...




Chanty4u
MVP
MVP

yes, you are correct,

but one or two if doesn't make any issue i believe ,  if it is complex and multiple if conditions if you use in front end it causes performance issue.

read this

If statement vs Set analysis

rahulpawarb
Specialist III
Specialist III

I 100% agree with Chanty! While loading the data create a flag field with definition of $(bCondition) i.e. 1 or 0; later you can consume it in set expression as Sum({<flag={1}>}Adults).


Regards!

Rahul Pawar