cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Can I display one field or another depending on filter values?

NewLearner1
Explorer
0 Likes
486

Hello, I'm new to SAC and still learning how it works and I,ve stumbled upon a headscratcher. 

I have a requirement where, in a table with multiple rows and columns, I'd like to display Field1 if the country filter value is set to Canada, and Field2 if the filter is set to US. All other fields in the table would be the same. 

The filter is an All Pages filter. 

I think this is feasable leveraging scripting, but I'm not sure how to go about it, any help would be appreciated. 

Thank you!

Accepted Solutions (0)

Answers (2)

Answers (2)

JBARLOW
Active Contributor
0 Likes

As Nikhil has said, you can capture the filter value with a script. 

You can then use script to add/remove dimensions from a table. 

The code below uses the value selected in a dropdown, but you could just as easily use... If filter value =x etc 

E. G. Apologies for the small image, posting on my phone 

Screenshot_20250318_220355_Word.jpg

not sure if it's allowed, but...

https://cadenceanalytics.co.uk/store

N1kh1l
Active Contributor
0 Likes

@NewLearner1 

Its not clear on where you want to display the field when you say "I'd like to display Field1 if the country filter value is set to Canada, and Field2 if the filter is set to US. All other fields in the table would be the same. "

Assuming you want to display as Information you could try the below approach.

1. Use getDimensionFilters of Filedatasource to read the story filter values ( US or Canada)

FileDataSource.getDimensionFilters(dimension: string|+DimensionInfo)

 2. Once you have read and stored the value assign the required value  in a variable using a simple IF statement. Once assigned to variable you could assign it to a dynamic Text variable and show it as information.

Hope this helps !

Nikhil