Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Independent validation for trusted, AI-ready data integration. See why IDC named Qlik a Leader: Read the Excerpt!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Text Boxes, linking values

I have three text boxes, let's call them Object IDs A, B and C.

A=1, B=2, therefore I want C to equal the average, 2.5.

I know how to write a lengthy if statement but I can't work out how to write: =(A+B)/2

Any ideas?

Thanks in advance.

4 Replies
sathishkumar_go
Partner - Specialist
Partner - Specialist

Hi

Use Sum function......

tseebach
Partner - Creator III
Partner - Creator III

To do that you need to write a macro that reads the value of A and B, then does the calculation and puts that into C. And have that to be triggered on some event.

I guess it should look something like this:

set objA = ActiveDocument.GetSheetObject("A")
set objB = ActiveDocument.GetSheetObject("B")
set objC = ActiveDocument.GetSheetObject("C")

objC.SetText = objA.GetText + objB.GetText

Not applicable
Author

Thanks for the above. Is tehre any way to do this without running a macro? I'd like the user to see it without having to press anything to calculate it.

Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP

Can you define 3 variables and show the variables in the text boxes. To declare the variables in the load script, use following:

LET var_A = 1;

LET var_B = 2;

SET var_C = '(var_A + var_B)/2';

notice the SET for var_C - this way, the value will be re-evaluated every time any of the variables is changing. You can also declare those variables in the runtime, using "Variables Overview" under "Settings".

good luck!

Oleg

Ask me about Qlik Sense Expert Class!