TOCSV DAX Function (Text)

Converts the records of a table into a CSV (comma-separated values) text.

Syntax

TOCSV ( <Table> [, <MaxRows>] [, <Delimiter>] [, <IncludeHeaders>] )
Parameter Attributes 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

Scalar A single string value.

Result in CSV format.

» 1 related function

Examples

DEFINE MEASURE Sales[ByCountry] =
	VAR SalesByCustomer = 
	    ADDCOLUMNS ( 
			VALUES ( Customer[CountryRegion] ), 
			"Amount", [Sales Amount] 
		)
	VAR Result = TOCSV (  SalesByCustomer, 3, ",", FALSE  )
	RETURN Result
EVALUATE
SUMMARIZECOLUMNS ( 'Customer'[Continent], "By Country CSV", [ByCountry] )
Continent By Country CSV
Asia Australia,7638059.93580003
Turkmenistan,118336.552
Thailand,63107.118
North America United States,10312118.2484997
Canada,885208.0705
Europe Germany,2519890.79830002
United Kingdom,3621032.15870003
France,1109665.43230001

Related functions

Other related functions are:

Last update: Dec 1, 2022   » Contribute   » Show contributors

Contributors: Alberto Ferrari, Marco Russo

Microsoft documentation not available.
The function may be undocumented or unsupported. Check the Compatibility box on this page.

2018-2022 © SQLBI. All rights are reserved. Information coming from Microsoft documentation is property of Microsoft Corp. » Contact us   » Privacy Policy & Cookies

Context Transition

This function performs a Context Transition if called in a Row Context. Click to read more.

Row Context

This expression is executed in a Row Context. Click to read more.

Iterator

Not recommended

The use of this function is not recommended. See Remarks and Related functions for alternatives.

Not recommended

The use of this parameter is not recommended.

Deprecated

This function is deprecated. Jump to the Alternatives section to see the function to use.

Volatile

A volatile function may return a different result every time you call it, even if you provide the same arguments. Click to read more.

Deprecated

This parameter is deprecated and its use is not recommended.

DirectQuery compatibility

Limitations are placed on DAX expressions allowed in measures and calculated columns.
The state below shows the DirectQuery compatibility of the DAX function.

Contribute

Want to improve the content of TOCSV? Did you find any issue?
Please, report it us! All submissions will be evaluated for possible updates of the content.


This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.