Displaying Table Measures based on filter

Hello All,

I have a metric set that has column measures for transaction counts, prior year count, and the variance %. In the same metric set I have the same columns but for amounts.

I want to display this metric set on a dashboard as table with the ability to display either the count columns or the amount columns only based on a filter. Is this possible with creating a layer with two separate tables? Filter.pdf (118.7 KB)

Hi Everardo,

If I have understood what you’re trying to achieve, this can be done by using the “hidden” property which value (true, false) will depend on the setting of your radio button list (that should be linked to a hierarchy for getting its values). Your radio button list has to be set to avoid multiple choices.
something like this set on the Change Value event of your radio button list should do the job:

var adapters = this.parentView.control.adapters;
var tableForCountAdapter = null;
var tableForAmountAdapter = null;
for (var index = 0; index < adapters.length; index++)
{
// always check that you’re not pointing to a null value, just in case…
if (adapter)
{
var adapter = adapters[index];
var adapterName = adapter.name;
if (adapterName === “theScriptNameOfYourTableForCount”)
{
tableForCountAdapter = adapter;
}
if (adapterName === “theScriptNameOfYourTableForAmount”)
{
tableForAmountAdapter = adapter;
}
}

vpRadioButtons = this.parentView.control.getViewParameterByName(“theScriptNameOfYourRadioButtonList”);

var radioButtonArray = vpRadioButtons.parameterValue.values;
// just to be sure that there is a value set…
if (radioButtonArray === null || radioButtonArray.length <= 0)
{
// no choice has been set
// And the Lord says “thou should always set a default value!”
tableForAmountAdapter.hidden = true;
tableForAmountAdapter.hidden = true;
}
else
{
// a value is set
var radioButtonUniqueName = radioButtonArray.first().uniqueName;
//here I assume that your hierarchy is set on the Id, in order to be sure
// just set “debugger;” at this level in order to check the uniqueName structure returned
// and then replace the “.A.Id” by the value corresponding to your hierarchy
var radioButtonId = Number(radioButtonUniqueName.replace(".A.Id",""));
// let’s say that the Id 1 corresponds to the first value of your filter (I assume that it’s “Count”)
// and Id 2 corresponds to the “Amount” choice
if (radioButtonId === 1)
{
tableForAmountAdapter.hidden = true;
tableForACountAdapter.hidden = false;
}
if (radioButtonId === 2)
{
tableForAmountAdapter.hidden = false;

tableForCountAdapter.hidden = true;
}
}

I hope this helps,

Olivier

1 Like

I forgot:
you can set the “hidden” property for the table that has to be hidden by default thru the GUI (in its Layout)

1 Like

Hi @romero.olivier
thank you for the reply and solution. I will attempt your script and let you know how it goes.

I should have been more detailed in my original request. I actually have one table with columns for both amounts and counts (see attached).


Is there a similar script to filter/hide columns within the same table instead of two separate tables?

Hi Everardo,
Is there something that prevents you from having two Metric Sets based on the same Data Cube? What I have called “table” in the script is a Metric Set. You just need to link the filters, if you have any, to both in order to have the rows filtered in the same way.