Calculated field with parameters

Hello!

I want to make a calculated field that will connect to my Parameter and filter:
image

if All Events is chosen then show me {Safety Events} = ‘true’ AND {Safety Events} = ‘false’
If Only Safety then show me only {Safety Events} = ‘true’

I tried this calculated field:
if(
{Safety Events} = ‘true’, ‘Only Safety’,
{Safety Events} = ‘true’ OR {Safety Events} = ‘false’, ‘All Events’
)

and also this:
ifelse(
${pSafety}= ‘Only Safety’, {Safety Events} = ‘true’,
${pSafety}= ‘All Events’, {Safety Events} = ‘true’ and {Safety Events} = ‘false’,
“Unknown”
)

It doesn’t work, how can i make it happened?
Thanks

Hi @InbalK,

Thanks for your question, I’ll try to help based on the scenario you’ve given.

I’m using a sales dataset, so the first thing I did was create a calculated field cfSafetyEvents that evaluates a row to be either true or false.

I then added a string parameter pChoice with a Static default value of “All Events” and a List control cChoice with 2 specific values defined:

All Events
Only Safety

I then created a calculated field as follows:
cfSaftetyEventsEvaluation - ifelse(cfSafetyEvents="true" AND ${pChoice}="Only Safety","Only Safety","All Events")

Finally, I created a filter that uses the pChoice parameter for my visual as follows:

Now when I select “All Events” in the control, I get this result:

And when I select “Only Safety” I see this instead:

Let me know if this helps and provides a solution for you.

Many Thanks,
Andrew

2 Likes

It works! Thank you very much!

2 Likes