Description:
This function returns a numeric code for the first character in a text string. The returned code corresponds to the character set used by your computer.
Syntax: CODE (Text)
Remarks
Example
You can use the EXACT to test text being entered into a document. The CODE function can be used in any database where you have stored characters or other text values and you want to return the corresponding code number for those characters and perhaps write that code value to another member. In this case it's possible to access this "CODE" value with the help of this function. This function displays a character as its code number after the function computes the parameter supplied to this function and determines which number corresponds with the given specified character.
=CODE ("A") |
-equals 65 |
=CODE ("N") |
-equals 78 |
=CODE ("!") |
-equals 33 |
Let us take the example of a database in PowerOLAP where we have certain text values for name, last name, city, country etc., and we need to manipulate these text values and arrive at results with different permutations and combinations. We shall use this example in this case to ascertain the CODE value based on the information provided by the "Continent" parameter that has the values for continent names, and which values are supplied to the function. In this case, we have written a formula in the appropriate cube in PowerOLAP, pulling in the value from the "Continent" field and then writing that value to this formula in order to calculate the result of the "CODE" function. The formula then calculates the "Code" element as a number that corresponds to the character supplied as the parameter and which is translated using the ASCII standard.
The formula above writes values into the "StringDataFunctions" cube to the "String Data Manipulations" dimension into the member named "Code" by calculating the appropriate value for this member, deriving the base from the "Continent" member in the "String Values" dimension which forms the parameter supplied to this function and it is for this parameter that the corresponding number code value is returned.