Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Enable/Disable Expression from Script

Is it possible to enable or disable expressions from the script? I know this can be done from creating a macro to run OnOpen..however, I don't want to prolong the opening of the document. I also want to avoid using IF statements in my expressions. Any ideas? Thanks!

1 Solution

Accepted Solutions
Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP

Unfortunately, Enable/Disable property cannot be defined with an expression, and therefore the only way to change it is via macro. I think I saw something about improving it in version 9, but I'm not totally sure...

The only work around that I could suggest is to keep duplicate copies of your charts/objects and play with the "Show condition" for those objects - those conditions can be calculated via expressions, and therefore you can control them from the script.

Hope it helps,

Oleg

View solution in original post

8 Replies
Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP

Unfortunately, Enable/Disable property cannot be defined with an expression, and therefore the only way to change it is via macro. I think I saw something about improving it in version 9, but I'm not totally sure...

The only work around that I could suggest is to keep duplicate copies of your charts/objects and play with the "Show condition" for those objects - those conditions can be calculated via expressions, and therefore you can control them from the script.

Hope it helps,

Oleg

Not applicable
Author

Thanks for the quick response. I'll take your suggestion into consideration.

Not applicable
Author

You can, however, drop a FIELD from a script... and you can do this based on the particular user using Section Access. Check out 30.8Dynamic Data Reduction in the manual

Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP

Anthony,

good catch, I haven't thought about it!

What happens to the expressions, thought? If we DROP or even OMIT the field [Cost], based on Section Access, and we have an expression for Margins:

=(sum(Sales) - sum(Cost))/sum(Sales)

What is going to happen to the expression? Is it going to be automatically removed or would just show nulls ?

thanks!

Oleg

Not applicable
Author

I think it will just show nulls and will not disable the expression from the graph ....

yblake
Partner - Creator II
Partner - Creator II

Bonjour Philippe,

This is a work around implemented for one of our projects, to change dynamically a column content, depending on dynamic criterias :

This expression will show different calculations, depending on IdColumn dimension value :

=pick(match(only(IdColumn),'A-1','N','O','M','A','A/A-1','A/O'),
num(sum(Turnover*_Y1*Change),'# ##0,0;-# ##0,0'),
num(sum(Turnover*_FM*Change),'# ##0,0;-# ##0,0'),
num(sum(Turnover*_F0*Change),'# ##0,0;-# ##0,0'),
num(sum(Turnover*_M0*Change),'# ##0,0;-# ##0,0'),
num(sum(Turnover*_Y0*Change),'# ##0,0;-# ##0,0'),
num((sum(Turnover*_Y0)/sum(CA*_Y1))-1,'0,0%'),
num((sum(Turnover*_Y0)/sum(CA*_F0))-1,'0,0%'))

In this example, IdColumn is last dimension of the pivot table, and loaded from an InLine table as an unliked table (called a "logical" island in QV documentation) :

LOAD * INLINE [
IdColumn, ColumnName
A-1, Réalisation A-1
N, Objectif mois
O, Objectif cumulé
M, Réalisé mois
A, Réalisé cumulé
A/A-1, Ecart réalisé / A-1
A/O, Ecart réalisé / Objectif
];

You may use same kind of work around, replacing IdColumn dimension values, i.e by a calculated dimension using ValueList or ValueLoop.

note however that you can change dynamically your table content, but you will always have the same number of columns displayed.

Bon courage

Not applicable
Author

Yves,

Merci beaucoup.

That works perfectly...

Philippe

Not applicable
Author

very nice work around.

Thanks a lot

Greetz, Dirk