Hi, is there a way to use CL to create a calculated column in a table?
I want students to calculate and enter probabilities in one column and have the table automatically multiply those probabilities by 50 and show the result in the next column.
This should do the trick, assuming your probabilities are in column 1 and the product should be in column 2. If you need another row, just duplicate the code and change the (1,1) and (1,2) to (2,1) and (2,2), respectively.
cellContent(1,2): when isDefined(this.cellNumericValue(1,1)) "${numericValue("${this.cellNumericValue(1,1)}*50")}" otherwise ""
I wanted to do something similar but instead take the square root of the number in cell(1,1).
I used the same code but wanted instead of multiplying by 50 I tried ^0.5.
I get an error when raising the number to 1/2 (0.5) but it works when square the number (ie ^2). I also tried ^(0.5) and it also gets an error.
Any ideas?
We make some assumptions for single digits since \sqrt{}9, for example, doesn’t mean anything. But don’t make that assumption once there are two digits since \sqrt10 could mean \sqrt{1}0 or \sqrt{10}
Not necessarily. What you’re doing there is interpolating the numericValue as part of a string with \sqrt, and then performing an evaluation on that string. If you want to inject a numeric value directly, use simpleFunction
(Simplified for generalization and using “” for formatting here)
This also makes it a bit easier to perform the operation repeatedly. You can assign the function to a variable and then call on the variable over and over