Hi,
I’ve the following case: I’ve set a filter interaction on a table visualization, this interaction changes the value of a filter control. What I need is to show on a label the current selected value of the filter, does anyone know how to do that?
How to show in a label the value of a current filter?
You can insert the filter value inside a label with a script. Which type is your filter?
label1.labelText=this.parentView.control.getViewParameterByName(“viewParameter1”).parameterValue.values[0].uniqueName.split(".")[0]
I’ve tested on a value filter and if you want to select more values from the table you must concatenate inside the label text.
Please let me know if it is fine.
This works, the problem is where to put it so I can set the label after I click on a table row. I’ll explain wtih an image:
I’ve set a filter interaction on the table (number 1 on the figure), this interaction sets the filter (number 2), and this filters the table (number 4), I added a script on the click event of table number 1, the problem is that It gets the last value and not the current value of the filter number 2 as you can see the figure. If you look at the label (number 3), you can see that it has the last value of the filter (number 2) and not the value that I just clicked.
The click event on table 1 has two scripts: the one generated by the “filter interaction” and my script with the code to update the label. So my problem is how to get the current value of the filter 2 and not the value that was there before I clicked
You can try with a timeout function:
setTimeout(function(){
//update label
}, 1500);
or you can add the same code to “Parameter value changed” on filter number 2.
Have you tried changing the order of the 2 click event scripts? Use the arrows to move them up and down.
Thanks guys! I changed the order of the events and it did work!
@costin.manea I am trying your solution here but my info is coming from OLAP cube so for a single parameter selection I will end up in Data Label with something in this format: [Operation].[Organization].[Los Angeles] - I can figure out how to remove [Operation].[Organization]. and brackets from this OLAP hierarchy as I select members from the parameter dropdown but wondering how you do what you suggested above (i.e. ‘concatenating multiple selections inside the label text’ - iow, if you had an example by any chance when I am selecting more than one value.)
Thank you.
Hello @semir.taletovic,
I do not have an example currently but if the script it’s working like you said for all values you can try to split it again.
If the script from above, label1.labelText=this.parentView.control.getViewParameterByName(“viewParameter1”).parameterValue.values[0].uniqueName.split(".")[0] is providing to you [Operation].[Organization].[Los Angeles], you can split again by (".") and you will receive 3 substrings. The last one, [2], will contain only [Los Angeles]. Furthermore, if the brackets are not needed you can remove it using the substring/split function. Probably you will need a dynamic formula in order to remove [] and you can use the indexof or something like this.
Hope this helps!
Hi - I think many cases can probably be solved starting in version 7 by displaying the slicer hierarchy in a visualization such as a data label. Just add it to the Data Analysis Panel’s Visualization tab like any other hierarchy or you can add it as a keyword in the properties.