Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi community,
How can I determine if a dimension or a metric is selected in the new straight table?
I need use conditional for metrics depending on whether there are dimensions selected or not, is there an option with the ObjectId that could be manipulated with variables?
Thanks!
Hey,
You can use conditional expressions to show or hide columns in a straight table based on certain conditions. For example, you can use the ''GetFieldSelections()'' function to check if a specific dimension or measure is selected and then use an if statement to show or hide a column based on the result.
Here’s an example of how you might use a conditional expression to show or hide a column based on whether a specific dimension is selected:
if(GetFieldSelections([DimensionName])='Value', 1, 0)
You can enter this expression in the ''Show column if'' field of the column’s properties in the straight table’s properties panel.
Hi Sorrakis,
if I get you right, the getSelectedCount() function in the column show condition would help.
You can set the column to show, for example, if in the field MyField the selected count is greater than 0.
Simply type =getSelectedCount(MyField) > 0 in the "Show column if" box.
Hope that helps.
Kind regards from Brussels,
Thilo
Hi mates,
Thanks but maybe I don't explain well my problem...
I'm using new straight table chart object (version May 2023) . I Know about getselectedcount, getfieldselections, variables.... but in this object you can select the measures and dimensions to show or hide (Ad-Hoc similar)
The question is.... How I know when the field is visible or not? (ej: If city is visible then hide Sales) - In the properties of Sales you can use conditional expression.
but how is the expression with any city value selected? 😃
Thanks!
That would be a good use case for the new chart-level scripting: loop through the currently shown dimensions and hide/show measures based on the shown dimensions.
Chart-level scripting, however, is not (yet?) available for the new Straight Table visualisation.
In your specific case, I'd use the traditional table to get better control of what is shown to the end user.
It'd be thoroughly clunky, but this could perhaps be handled using GetObjectField(), e.g.
If(Match('City', GetObjectField(0), GetObjectField(1), GetObjectField(2), GetObjectField(3), GetObjectField(4)),1,0)
It'd run pretty long depending on how many dimensions you can have, but I think this or some variant of it would work.
This works fine! Just put the statement in a variable and refer to the variable in the show=conditions.