Logo
MicroStrategy REST API API Documentation

Update a metric

PUT {{baseUrl}}/api/model/metrics/:metricId

Updates a specific metric in the changeset, based on the definition provided in the request body. It returns the metric's updated definition in the changeset.

In the request body, expression needs to be in either tree or tokens format. If both are provided, only tree is used.

  • Tokens are a semi-structured representation of MicroStrategy expression text that includes object references. For example, let’s say a metric expression is Sum(Cost). When the metric expression is represented as tokens, the text is broken down into pieces (tokens) with information about what these pieces represent in the metadata: (Sum, SumID), ((), (Cost, CostID), ()).

The changeset ID can be obtained using the changeset creation API. An authorization token is required to execute the request and can be obtained using Authentication endpoints.

To save the change in the metadata, commit using the changeset commit API.

 

Body PARAM

Key Datatype Required Description 
showExpressionAs
null This parameter specifies the format in which the expressions are returned in response. This parameter applies to the expressions in a fact or attribute and custom expressions used in a filter, prompt, security filter, custom group, etc. Expressions are presented in the following formats: * "text": A human readable, but non-parsable text, describing the expression. This is the default format that is always returned in the response. * "tree": A tree data structure fully defining the expression. This format can be used if you want to examine and modify the expression programmatically. * "tokens": A list of parsed tokens. This format can be used if you want to examine and modify the expression using the parser component. Note that generating tokens requires additional time. Tokens are a semi-structured representation of MicroStrategy expression text that includes object references. For example, let’s say a filter expression is "Revenue > Cost". When the filter expression is represented as tokens, the text is broken down into pieces (tokens) with information about what these pieces represent in the metadata: ("Revenue", Revenue_ID), (">", GreaterThan_ID), ("Cost", Cost_ID). If omitted, the expression is returned in "text" format. If `tree`, the expression is returned in "text" and "tree" formats. If `tokens`, the expression is returned in "text" and "tokens" formats.
showFilterTokens
null Specify whether the "condition" in threshold is returned in "tokens" format, along with "text" and "tree" formats. The "condition" in threshold is presented in the following formats: * "text": A human readable, but non-parsable text, describing a condition's qualification. * "tree": A tree data structure fully defining the condition's qualification. * "tokens": A list of parsed tokens that define a condition's qualification. Be aware that generating tokens requires additional time. If omitted or `false`, only "text" and "tree" formats are returned. If `true`, all "text", "tree" and "tokens" formats are returned.
showAdvancedProperties
null Specify whether to retrieve the values of the advanced properties. The advanced properties are presented in the following groups: "vldbProperties": A list of properties as determined by the common infrastructure. If omitted or false, the API will not return advanced properties. If true, all applicable advanced properties are returned.



HEADERS

Key Datatype Required Description 
Curl
curl -X PUT 'baseUrl/api/model/metrics/:metricId?showExpressionAs=&showFilterTokens=&showAdvancedProperties=' -H 'X-MSTR-AuthToken: authToken' -H 'X-MSTR-MS-Changeset: rd_changesetId' -d '{"information":{"destinationFolderId":"publicObjectsFolderId","subType":"metric","name":"Cost Comparison"},"expression":{"text":"Sum(Cost)","tokens":[{"level":"resolved","state":"initial","value":"Sum","type":"function","target":{"dateCreated":"2001-01-02T20:47:35.000Z","dateModified":"2021-02-26T03:18:40.000Z","versionId":"93B1FFD040F7CBECF3C3378D5391AA35","primaryLocale":"en-US","objectId":"8107C31BDD9911D3B98100C04F2233EA","subType":"function","name":"Sum","description":"Returns the sum of all values in the ValueList. This is a group-value function."}},{"level":"resolved","state":"initial","value":"\u003c","type":"character"},{"level":"resolved","state":"initial","value":"UseLookupForAttributes","type":"identifier"},{"level":"resolved","state":"initial","value":"=","type":"function"},{"level":"resolved","state":"initial","value":"False","type":"boolean"},{"level":"resolved","state":"initial","value":"\u003e","type":"character"},{"level":"resolved","state":"initial","value":"(","type":"character"},{"level":"resolved","state":"initial","value":"Cost","type":"object_reference","target":{"dateCreated":"2001-09-18T20:21:56.000Z","dateModified":"2021-02-26T03:18:52.000Z","versionId":"66BBCD784D52223085BBC2BC81EB8F16","primaryLocale":"en-US","objectId":"7A4ABE9111D5AC6FC000D98A4CC5F24F","subType":"fact","name":"Cost"}},{"level":"resolved","state":"initial","value":")","type":"character"},{"level":"resolved","state":"initial","value":"{","type":"character"},{"level":"resolved","state":"initial","value":"~","type":"character"},{"level":"resolved","state":"initial","value":"+","type":"character"},{"level":"resolved","state":"initial","value":",","type":"character"},{"level":"resolved","state":"initial","value":"\u003c|","type":"other"},{"level":"resolved","state":"initial","value":"Year","type":"object_reference","target":{"dateCreated":"2001-01-02T20:48:10.000Z","dateModified":"2021-02-26T03:18:50.000Z","versionId":"CF8EEF064DCB3A0CFFC3439EF5ADEE47","primaryLocale":"en-US","objectId":"8D679D5111D3E4981000E787EC6DE8A4","subType":"attribute","name":"Year"}},{"level":"resolved","state":"initial","value":"*","type":"character"},{"level":"resolved","state":"initial","value":"}","type":"character"},{"level":"resolved","state":"initial","value":"\u003c","type":"character"},{"level":"resolved","state":"initial","value":"[Select a Quarter]","type":"object_reference","target":{"dateCreated":"2001-10-19T16:59:45.000Z","dateModified":"2016-02-02T21:42:28.000Z","versionId":"BC17244611E5C05100000080EF75F6D3","primaryLocale":"en-US","objectId":"E638359211D5C49EC0000C881FDA1A4F","subType":"filter","name":"Select a Quarter"}},{"level":"resolved","state":"initial","value":";","type":"character"},{"level":"resolved","state":"initial","value":"@","type":"character"},{"level":"resolved","state":"initial","value":"3","type":"integer"},{"level":"resolved","state":"initial","value":"\u003e","type":"character"},{"level":"resolved","state":"initial","value":"|","type":"character"},{"level":"resolved","state":"initial","value":"[Last Quarter's]","type":"object_reference","target":{"dateCreated":"2001-10-10T13:50:20.000Z","dateModified":"2021-02-26T03:18:51.000Z","versionId":"28EA303A4A885EC20F1BC3BBD1AACD20","primaryLocale":"en-US","objectId":"2437C03311D5BD85C000F98A4CC5F24F","subType":"role_transformation","name":"Last Quarter's","description":"Transforms Quarter to Last Quarter, Month to Last Quarter's Month, Day to Last Quarter's Day"}},{"level":"resolved","state":"initial","value":"|","type":"character"},{"level":"resolved","state":"initial","value":"","type":"end_of_text"}]},"dimty":{"dimtyUnits":[{"dimtyUnitType":"report_base_level","aggregation":"normal","filtering":"apply","groupBy":true},{"dimtyUnitType":"attribute","target":{"objectId":"8D679D5111D3E4981000E787EC6DE8A4","subType":"attribute","name":"Year"},"aggregation":"first_in_fact","filtering":"absolute","groupBy":true},{"dimtyUnitType":"role","target":{"objectId":"2437C03311D5BD85C000F98A4CC5F24F","subType":"role_transformation","name":"Last Quarter's"}}],"excludeAttribute":false,"allowAddingUnit":true},"conditionality":{"filter":{"objectId":"E638359211D5C49EC0000C881FDA1A4F","subType":"filter","name":"Select a Quarter"},"embedMethod":"metric_into_report_filter","removeElements":true},"metricSubtotals":[{"definition":{"objectId":"96C487AF4D12472A910C1ACACFB56EFB","subType":"system_subtotal","name":"Total"},"implementation":{"objectId":"B328C60462634223B2387D4ADABEEB53","subType":"system_subtotal","name":"Average"}},{"definition":{"objectId":"078C50834B484EE29948FA9DD5300ADF","subType":"system_subtotal","name":"Count"}},{"definition":{"objectId":"B328C60462634223B2387D4ADABEEB53","subType":"system_subtotal","name":"Average"}},{"definition":{"objectId":"00B7BFFF967F42C4B71A4B53D90FB095","subType":"system_subtotal","name":"Minimum"}},{"definition":{"objectId":"B1F4AA7DE683441BA559AA6453C5113E","subType":"system_subtotal","name":"Maximum"}},{"definition":{"objectId":"F225147A4CA0BB97368A5689D9675E73","subType":"system_subtotal","name":"Aggregation"},"implementation":{"objectId":"078C50834B484EE29948FA9DD5300ADF","subType":"system_subtotal","name":"Count"}}],"aggregateFromBase":false,"formulaJoinType":"inner","smartTotal":"decomposable_false","dataType":{"type":"int64","precision":0,"scale":0},"format":{"header":[{"type":"number_category","value":"0"},{"type":"number_decimal_places","value":"2"},{"type":"number_thousand_separator","value":"true"},{"type":"number_currency_symbol","value":"$"},{"type":"number_currency_position","value":"0"},{"type":"number_format","value":"#,##0.00;(#,##0.00)"},{"type":"number_negative_numbers","value":"3"},{"type":"background_fill_color","value":"3355443"},{"type":"background_pattern_style","value":"1"},{"type":"background_fill_style","value":"0"},{"type":"background_gradient_angle","value":"0"},{"type":"background_gradient_x_offset","value":"0"},{"type":"series_fill_style","value":"0"},{"type":"series_fill_color","value":"8388608"},{"type":"series_gradient_angle","value":"0"},{"type":"series_gradient_x_offset","value":"0"}],"values":[{"type":"number_category","value":"0"},{"type":"number_decimal_places","value":"0"},{"type":"number_format","value":"#,##0;(#,##0)"}]},"subtotalFromBase":false,"columnNameAlias":"test","metricFormatType":"reserved"}'

ENDPOINTS