Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

what if analysis

I have to make a what-if analysis, where the user sets the values of some variables (using some sliders) and then qlikview calculates the results based on the variables

in this topic  http://community.qlik.com/message/203731#203731  they told me i have to make a partial reload to calculate the results

but i cannot do this since the end user cannot do a partial reload using qlikview via web

so is there a way to create working what-if analysis in qlikview??

Edited:
i have attached an example, with a simple what if analysis and alla the things discussed in this topic

1 Solution

Accepted Solutions
swuehl
MVP
MVP

If you can't do a (partial) reload, you would need to move your new field calculations to the frontend, i.e. use an expression or calculated dimension instead. Not sure if this is possible or easy doable in your case, to help you more, you would need to give more information about your data model, the what-if analysis you want to do and the calculations used in the script.

Probably best to post a small demo app that demonstrates your issue here to the forum.

View solution in original post

10 Replies
swuehl
MVP
MVP

If you can't do a (partial) reload, you would need to move your new field calculations to the frontend, i.e. use an expression or calculated dimension instead. Not sure if this is possible or easy doable in your case, to help you more, you would need to give more information about your data model, the what-if analysis you want to do and the calculations used in the script.

Probably best to post a small demo app that demonstrates your issue here to the forum.

Not applicable
Author

I'm not an expert, thus correct me if i'm wrong:


i have some data loaded from an excel file, that are saved into a field

i have a variable which the user can modify using the slider

i have to dinamically make calculations with those 2 data (for example multiply the values taken from excel and the variable)

if i understand correctly, these calculations can only be done within the script

otherwise i would need something like X variables to contain all the values of the excel file

i am really confused about that

swuehl
MVP
MVP

I think it should be possible to calculate all is needed in the frontend.

Could you post a small sample (e.g. the excel file), doesn't need to contain your real data, but should demonstrate your issue?

Not applicable
Author

I have edited the discussion and attached an example

swuehl
MVP
MVP

If you want to calculate something in the frontend, you need to use a chart object where you can use expressions, just a table box will not do the job.

For example create a straight table chart object with dimension name and as expression

= quantitiy * vVariable

This should dynamically re-calculate your values when you move the slider / change the variable.

Hope this helps,

Stefan

Not applicable
Author

Ok, i wrote a bad example: my situation is a little more complicated

I have changed the attached file with a new one

As you can see i have 3 variables, and based on the content of the "name" field i load a different value and assign it to the "variable" field

This way i can then use this field to make sum and other aggregations

But i have to do this outside the load script

If i make an expression in the chart table (as your example shows), i cannot use that value outside the chart

swuehl
MVP
MVP

That's indeed only a little bit more complicated.

You just need to convert your script expression in a front end expression, so I think you can use an expression like

=pick(match(name,'a','b','c'),vVariableA,vVariableB,vVariableC)

to pick the right variable for your name and then just multiple by your quantity or if you want to have an aggregate over all your names:

=sum(aggr(quantity*pick(match(name,'a','b','c'),vVariableA,vVariableB,vVariableC),name))

See also attached,

Stefan

Not applicable
Author

Thanks for your time Stefan, and thanks for the hints

But this way it's gonna be too complicated soon

A friend of mine suggests to define some variables to contain the values i need

But even in this case i get into some unexpected errors

I have edited the discussiond and attached a new file

As you can see i create vVariable to contain tha value i need, whit the various "if" in the expression

Then i create vResult, expecting to multiply vVraiable with quantity

But as you can see in th table it only shows some -

Is this an expected behavoir?

How can i make calculations with variables?

swuehl
MVP
MVP

You are almost there.

Your vVariable including the multiple if() functions is not much different from the pick(match()) combination, by the way.

If you want to use variables, one big point is to know how variables are evaluated (in which context). See

http://www.qlikfix.com/2011/06/08/not-all-variables-are-created-equal/

for quite a good explanation of what I mean.

If you want to evaluate the sum of vVariable*quantity e.g. in a text box, I believe you need advanced aggregation, because you need to evaluate the variable per dimension name.

Please see attached.

Hope this helps,

Stefan