|
| 1 | +--- |
| 2 | +title: CSV command |
| 3 | +--- |
| 4 | + |
| 5 | +This command will send output to a file based on the results of a DAX query |
| 6 | + |
| 7 | +## Syntax |
| 8 | + |
| 9 | +``` |
| 10 | +DSCMD FILE <OutputFile> [OPTIONS] |
| 11 | +``` |
| 12 | + |
| 13 | +## Arguments |
| 14 | + |
| 15 | +| Name | Description | |
| 16 | +|---|---| |
| 17 | +| <OutputFile> | The path and name of the file to which the CSV data will be written | |
| 18 | + |
| 19 | +## Options |
| 20 | + |
| 21 | +| Option | Description | |
| 22 | +| ---|---| |
| 23 | +| -h, --help | displays the help for the CSV command| |
| 24 | +| -s, --server <SERVER> | the name of the server to connect to | |
| 25 | +| -d, --database <DATABASE> | The name of the tabular database to export from | |
| 26 | +| -u, --userid <USERID> | The username to use for authentication (see [Authentication](../../authentication) for more details) | |
| 27 | +| -p, --password <PASSWORD> | The password to use for authentication (see [Authentication](../../authentication) for more details) | |
| 28 | +| -c, --connectionstring <CONNECTIONSTRING> | The connection string for the data source | |
| 29 | +| -f, --file <FILE> | A file containing a DAX query to be executed. Could be a text file or .dax or .daxx | |
| 30 | +| -q, --query <QUERY> | A string with the DAX query to be executed | |
| 31 | +| -t, --filetype <VALUE>| Can be one of the following values ( UTF8CSV, UNICODECSV, JSON, TAB, PARQUET ) if omitted the file extension is used <ul><li>.csv - UFT-8 csv file is generated</li><li>.txt - tab delimited file is generated</li><li>.json - a json file is generated </li></ul>| |
| 32 | +| -m, --parameter <PARAMETER=VALUE> | Parameter values to be passed into the query (see [-m --parameter option](#-m---parameter-option) below)| |
| 33 | + |
| 34 | +### -m --parameter Option |
| 35 | +If you have a DAX query with parameters you can pass these in using the `-m, -parameter` option, if you have multiple parameters in your query you can provide multiple parameter values |
| 36 | + |
| 37 | +In the following example the query has 2 parameters **@myColor** and **@myCategory** which are passed in using 2 `-m` options |
| 38 | + |
| 39 | +eg. |
| 40 | +``` |
| 41 | +dscmd csv c:\temp\myquery.csv -s localhost\tab19 -d "Adventure Works DW" ^ |
| 42 | + -m myColor=Red ^ |
| 43 | + -m myCategory=Bikes ^ |
| 44 | + -q "EVALUATE FILTER('product', 'product[Color]=@myColor && 'product'[Category]=@myCategory)" |
| 45 | +``` |
| 46 | + |
| 47 | +## Examples |
| 48 | + |
| 49 | +The following example exports to a file called myquery.csv in the c:\temp folder and connects as the user running the command |
| 50 | + |
| 51 | +``` |
| 52 | +dscmd csv c:\temp\myquery.csv -s localhost\tab19 -d "Adventure Works DW" -q "EVALUATE 'product'" |
| 53 | +``` |
| 54 | + |
| 55 | +``` |
| 56 | +dscmd csv c:\temp\myquery.csv -c "Data Source=localhost\tab19;initial catalog=Adventure Works DW" -q "EVALUATE 'product'" |
| 57 | +``` |
0 commit comments