Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
pra_kale
Creator III
Creator III

Any option To..Too Many Variables creation

Hi,

I am developing one application in which requirement is to compare MTD Target Vs Achievement and YTD Target Vs Achievement.

I have almost 14 Metrics so naturally i have to create 28 Variables 14 for MTD and 14 for YTD this is only at company level comparison.

Similarly I have 10 channels so I am almost creating 280 variables  assuming Targets are entirely different every where. I am creating 2 Buttons 1 for MTD and 2 for YTD so accordingly columns get's displayed in a chart.

Is there any alternative / approach to this or I have to create these many variables. Secondly, is there any option to manage such kind of too many variables. Thirdly, as I am going to use these variables in a expression for comparison my chart defiantly take time to load.

So can I approach to this situation any different way..Please suggest.

Thanks in Advance. 

6 Replies
swuehl
MVP
MVP

You can use dollar sign expansion of variables with parameter to have one variable for both MTD and YTD, potentially passing the channel as second parameter. Best case, one variable instead of 280.

From HELP:

Dollar-Sign Expansion with Parameters

Parameters can be used in variable expansions. The variable must then contain formal parameters, such as $1, $2, $3 etc. When expanding the variable, the parameters should be stated in a comma separated list.

Examples:

set MUL=’$1*$2’;

set X=$(MUL(3,7)); // returns '3*7' in X

let X=$(MUL(3,7)); // returns 21 in X

If the number of formal parameters exceeds the number of actual parameters only the formal parameters corresponding to actual parameters will be expanded. If the number of actual parameters exceeds the number of formal parameters the superfluous actual parameters will be ignored.

Examples:

set MUL=’$1*$2’;

set X=$(MUL); // returns '$1*$2' in X

set X=$(MUL(10)); // returns '10*$2' in X

let X=$(MUL(5,7,8)); // returns 35 in X

The parameter $0 returns the number of parameters actually passed by a call.

Example:

set MUL='$1*$2 $0 par';

set X=$(MUL(3,7)); // returns '3*7 2 par' in X

You can also hold all your variable definitions in an excel file, this might make it easier to maintain your variables.

See also

Variables

sunny_talwar

When you say variables, do you actually mean variables are you referring to them as expressions? Would you ever see all the chart all at once? If not then you can definitely have just two expressions (one for MTD and other one for YTD) and have them change based on the selections you make. Not sure how your data model looks like, so might be able to suggest anything specific here.

petter
Partner - Champion III
Partner - Champion III

It doesn't seem to me that you will need to make new "variables" for Channels. That might be the case for other dimensions that you think you need variables for. When you call it variables do you use the term as it is used in statistics and R?

Another thing to consider is that you can make variables in QlikView to referer other variables. Just like you do in a spreadsheet you can reference other calculations - endlessly. That can make the number of "expression variables" quite managable.

Besides storing expressions in variables you could actually have your expressions in fields to. Referencing a field in a data island will make the number of expression much easier to handle and you have benefits for the application that you can interactively switch between expressions being used with list boxes.

You can even combine the two approaches.

pra_kale
Creator III
Creator III
Author

Thanks for your Help.

As I am recently started development I am finding little bit difficult to implement the things which you mentioned..

But I have created a Moc Data Model (Application) similar to the original. But in this data model in expression I have created only 1 expression but the way I have mentioned earlier there are around 28 expression for 14 MTD and 14 for YTD. I have created the variables as well, the way I have created in original application.

Can you please make the corrections in this application so I can understand in better way..and implement in Original.

One problem I have notice in first place itself in overall sheet where I am giving Target only for Overall Achievement but this Target get implemented for channel level as well..why this is happing I don't know. for e.g. For Overall MTD Target is 10 and YTD Target is 30 but if you see values are in 'Red' and 'Green' colour for channel level as well. But, which is wrong as every channel has it's own MTD and YTD Targets...

Please Guide..

Thanks in Advance.

pra_kale
Creator III
Creator III
Author

Hi Sunny,

Thanks for your Help..

Below attached is the Moc Data Model. In this Data Model I have created only 1 expression i.e. on Submission, but as I have mentioned earlier there are almost 28 Expression 14 for MTD and 14 for YTD. In This data model I have created only 3 channels but there are almost 10 channels means I have to create 10 sheets each represent 1 channel. I have created the variables the same way I have created in Original Data model

Can you please help how I can minimises the number of variables.

Thanks in advance.

pra_kale
Creator III
Creator III
Author

Hi,

I am attaching the Moc data model created. In this Model I have created only 1 expression i.e. on Submission but in actual there are 14 expressions for MTD and 14 for YTD for all the channels. Can you please assist how I can minimise

the variables and use them in expression To compare the Target vs Achievement.

Thanks in advance.