Set Formula
{ setFormula }
Create/update a custom member or custom measure calculation.
Method
/API3/analytics/setFormula
- Enterprise Admin
- Domain Admin
- Pro
- Analyst
- Viewer
Input Parameters
Name
formulaData
Object Type
Description
The details of the Formula to add to the system.
Output Response
Successful Result Code
200
Response Type
string
Description of Response Type
Returns the created Formula ID
Notes
The logic for the formula must be supplied as a compliant PQL or MDX script. If the formula does not exist, a new one will be created.
Code Snippets
Use the Authentication API methods to generate an access 'key' or 'token' for use in code as shown below.
TypeScript
Curl
Java
C#
Python
PHP
curl -X POST \
-H "paToken: [[apiKey]]" \
-H "Accept: application/json,application/json;charset=utf-8,text/csv,text/csv;charset=utf-8,application/xml,application/xml;charset=utf-8,text/plain,text/plain;charset=utf-8" \
-H "Content-Type: application/json" \
"http://Your.Server.URL/API3/analytics/setFormula" \
-d '{
"formatString" : "formatString",
"dynamicCaption" : "dynamicCaption",
"description" : "description",
"parentDimension" : "parentDimension",
"parentHierarchy" : "parentHierarchy",
"msOlapProps" : {
"foregroundColorSyntax" : "foregroundColorSyntax",
"backColorSyntax" : "backColorSyntax",
"parentElement" : "parentElement"
},
"folderId" : "046b6c7f-0b8a-43b9-b35d-6489e6daee91",
"tags" : [ "046b6c7f-0b8a-43b9-b35d-6489e6daee91", "046b6c7f-0b8a-43b9-b35d-6489e6daee91" ],
"formulaSyntax" : "formulaSyntax",
"itemName" : "itemName",
"connectionId" : "046b6c7f-0b8a-43b9-b35d-6489e6daee91",
"id" : "046b6c7f-0b8a-43b9-b35d-6489e6daee91",
"solveOrder" : 0
}'
import com.pyramidanalytics.*;
import com.pyramidanalytics.auth.*;
import com.pyramidanalytics.model.*;
import com.pyramidanalytics.api.AnalyticsServiceApi;
import java.util.*;
import java.time.*;
public class AnalyticsServiceApiExample {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("http://Your.Server.URL/");
// Configure API key authorization: paToken
ApiKeyAuth paToken = (ApiKeyAuth) defaultClient.getAuthentication("paToken");
paToken.setApiKey("YOUR API KEY");
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//paToken.setApiKeyPrefix("Token");
// Create an instance of the API class
AnalyticsServiceApi apiInstance = new AnalyticsServiceApi();
// Initialize the formulaData parameter object for the call
FormulaData formulaData = ; // Create the input object for the operation, type: FormulaData
try {
UUID result = apiInstance.setFormula(formulaData);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling AnalyticsServiceApi#setFormula");
e.printStackTrace();
}
}
}
import * as PyramidAnalyticsWebApi from "com.pyramidanalytics";
// Create an instance of the API class
const api = new PyramidAnalyticsWebApi.AnalyticsServiceApi("http://Your.Server.URL")
// Configure API key authorization: paToken
api.setApiToken("YOUR API KEY");
const formulaData = ; // {FormulaData}
api.setFormula(formulaData).then(function(data) {
console.log('API called successfully. Returned data: ' + data);
}, function(error) {
console.error(error);
});
using System;
using System.Diagnostics;
using PyramidAnalytics.Sdk.Api;
using PyramidAnalytics.Sdk.Client;
using PyramidAnalytics.Sdk.Model;
public class setFormulaExample
{
public static void Main()
{
Configuration conf = new Configuration();
conf.BasePath = "http://Your.Server.URL/";
// Configure API key authorization: paToken
conf.ApiKey.Add("paToken", "YOUR_API_KEY");
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// conf.ApiKeyPrefix.Add("paToken", "Bearer");
GlobalConfiguration.Instance = conf;
// Create an instance of the API class
var apiInstance = new AnalyticsServiceApi();
// Initialize the formulaData parameter object for the call
var formulaData = new FormulaData(); // FormulaData |
try {
// Create/update a custom member or custom measure calculation.
Guid result = apiInstance.setFormula(formulaData);
Debug.WriteLine(result);
} catch (Exception e) {
Debug.Print("Exception when calling AnalyticsServiceApi.setFormula: " + e.Message );
}
}
}
import com.pyramidanalytics
from com.pyramidanalytics import ApiException
from com.pyramidanalytics import AnalyticsServiceApi
from pprint import pprint
# Configure API key authorization: paToken
api_config = com.pyramidanalytics.Configuration(host = 'http://Your.Server.URL/', api_key={ paToken:'YOUR_ACCESS_TOKEN' })
with com.pyramidanalytics.ApiClient(api_config) as api_client:
# Create an instance of the API class
api_instance = AnalyticsServiceApi(api_client)
# Initialize the formulaData parameter object for the call
formulaData = # FormulaData |
try:
# Create/update a custom member or custom measure calculation.
api_response = api_instance.set_formula(formulaData)
pprint(api_response)
except ApiException as e:
print("Exception when calling AnalyticsServiceApi->setFormula: %s\n" % e)
<?php
require_once(__DIR__ . '/vendor/autoload.php');
OpenAPITools\Client\Configuration::getDefaultConfiguration()->setHost('http://Your.Server.URL');
// Configure API key authorization: paToken
OpenAPITools\Client\Configuration::getDefaultConfiguration()->setApiKey('paToken', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// OpenAPITools\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('paToken', 'Bearer');
// Create an instance of the API class
$api_instance = new OpenAPITools\Client\Api\AnalyticsServiceApi();
$formulaData = ; // FormulaData |
try {
$result = $api_instance->setFormula($formulaData);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling AnalyticsServiceApi->setFormula: ', $e->getMessage(), PHP_EOL;
}
?>