Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
sorrakis01
Specialist
Specialist

CONDITIONAL - Show/Hide columns new straight table May 2023

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!

Labels (7)
6 Replies
Chirantha
Support
Support

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.

tealowk
Partner - Contributor III
Partner - Contributor III

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.

tealowk_0-1689149033761.png

Hope that helps.

Kind regards from Brussels,

Thilo

 

sorrakis01
Specialist
Specialist
Author

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)

sorrakis01_0-1689151194462.png

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.

sorrakis01_2-1689151419371.png

but how is the expression with any city value selected? 😃

Thanks!

 

tealowk
Partner - Contributor III
Partner - Contributor III

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.

Or
MVP
MVP

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.

marc_thomassen
Partner - Contributor III
Partner - Contributor III

This works fine! Just put the statement in a variable and refer to the variable in the show=conditions.