Skip to content

Commit 02e78c1

Browse files
ovrigorlukanin
authored andcommitted
docs(mdx): Write about formatting (#10016)
1 parent 4aa5b73 commit 02e78c1

File tree

1 file changed

+49
-1
lines changed

1 file changed

+49
-1
lines changed

docs/pages/product/apis-integrations/mdx-api.mdx

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,11 +180,59 @@ This is going to be harmonized in the future.
180180
181181
</InfoBox>
182182
183+
## Formatting
184+
185+
MDX API supports formatting for measures to control how values are displayed in Excel.
186+
187+
### Percent format
188+
189+
You can format measures as percentages using the `percent` format type:
190+
191+
```yaml
192+
cubes:
193+
- name: orders
194+
sql_table: ORDERS
195+
196+
measures:
197+
- name: completion_rate
198+
sql: "COUNT(CASE WHEN {CUBE}.status = 'completed' THEN 1 END) / COUNT(*)"
199+
type: number
200+
format: percent
201+
```
202+
203+
### Currency format
204+
205+
You can format measures as currency using the `currency` format type:
206+
207+
```yaml
208+
cubes:
209+
- name: orders
210+
sql_table: ORDERS
211+
212+
measures:
213+
- name: total_revenue
214+
sql: "{CUBE}.amount"
215+
type: sum
216+
format: currency
217+
```
218+
219+
Currency formatting is locale-aware and responds to the language configuration set via the `CUBE_XMLA_LANGUAGE` environment variable. This variable accepts either [Microsoft LCID (Locale Identifier)][link-lcid] values or language tags. The default value is `1033` (English - United States).
220+
221+
For example, to display currency values using the Netherlands locale (Euro with comma as decimal separator), you can use either:
222+
223+
```bash
224+
# Using LCID
225+
CUBE_XMLA_LANGUAGE=1043
226+
227+
# Using language tag
228+
CUBE_XMLA_LANGUAGE=nl-NL
229+
```
230+
183231
## Authentication and authorization
184232

185233
Authentication and authorization work the same as for the [SQL API](/product/apis-integrations/sql-api/security).
186234

187-
235+
[link-lcid]: https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-lcid/70feba9f-294e-491e-b6eb-56532684c37f
188236
[ref-excel]: /product/configuration/visualization-tools/excel
189237
[link-mdx]: https://learn.microsoft.com/en-us/analysis-services/multidimensional-models/mdx/multidimensional-model-data-access-analysis-services-multidimensional-data?view=asallproducts-allversions#bkmk_querylang
190238
[link-pivottable]: https://support.microsoft.com/en-us/office/create-a-pivottable-to-analyze-worksheet-data-a9a84538-bfe9-40a9-a8e9-f99134456576

0 commit comments

Comments
 (0)