TOCSV

Updated on

TOCSV is a DAX function that converts the records of a table into a CSV (comma-separated values) text format.

Syntax

TOCSV(
   Table,
   MaxRows,
   Delimiter,
   IncludeHeaders
)
Argument Properties Description
Table The table to be converted.
MaxRows Optional The maximum number of rows to be converted. A negative number means all rows are converted. Default is 10.
Delimiter Optional The field separator. Must be a non-empty constant string. Default is ‘,’.
IncludeHeaders Optional If true, the header row is included. Default is true.

Return Values

A string with CSV representation of the table.

Example

The following DAX query:

EVALUATE
{TOCSV(DimSalesTerritory)}

Returns:

'DimSalesTerritory'[SalesTerritoryKey],'DimSalesTerritory'[SalesTerritoryAlternateKey],'DimSalesTerritory'[SalesTerritoryRegion],'DimSalesTerritory'[SalesTerritoryCountry],'DimSalesTerritory'[SalesTerritoryGroup]
1,1,Northwest,United States,North America
2,2,Northeast,United States,North America
3,3,Central,United States,North America
4,4,Southwest,United States,North America
5,5,Southeast,United States,North America
6,6,Canada,Canada,North America
7,7,France,France,Europe
8,8,Germany,Germany,Europe
9,9,Australia,Australia,Pacific
10,10,United Kingdom,United Kingdom,Europe

Other functions related to TOCSV are:

Contribute » | Contributors: Rick de Groot
Microsoft documentation: https://learn.microsoft.com/en-us/dax/tocsv-function-dax

2023-2024 © BI Gorilla. All rights are reserved. Information from Microsoft docs is property of Microsoft Corp. | Privacy Policy