Export filters along with data

Id like to have what filters have been applied to a visual to be included in its CSV export.

I have a dropdown menu connected to an “Export as CSV” button and when I export I get the visual listed on the dropdown menu. The data in the export is filtered correctly, I would just like there to also be a line which includes the applied filters and amounts. Is this possible?

Thanks!

1 Like

Hi Pierre,

I’m not sure if this is helpful at all since the export in this example is to xlsx and is a script that is ran on a button click but this is what we use to export to Excel with the set parameters listed on the left hand side. Just be sure to change parameterValue.values = [ ExportTable.id ]; to whatever the script name is of the item you are trying to export.

// Get the export service.

var exportService = this.getService(‘ExportService’);

// Get the view service.

var viewService = this.getService(‘ViewService’);

// Create the export request.

var exportRequest =

new dundas.export.ExportRequest(

  {

    isLegacyExport: true,

    // Export Excel

    providerId: dundas.constants.STANDARD_EXCEL_EXPORT_PROVIDER_ID,

    viewData: this.getService("CanvasService").canvas.viewModel.businessObject.control

  });

// Create parameter value to pass to the request.

var parameterValue = new dundas.data.CollectionStringValue();

parameterValue.parameterId = dundas.constants.EXCEL_ADAPTERS_ID;

parameterValue.values = [ ExportTable.id ];

exportRequest.parameterValues.push(parameterValue);

//Multiple select

var parameterValue = new dundas.data.SingleNumberValue();

parameterValue.parameterId = dundas.constants.EXCEL_EXPORT_SELECTION_ID;

parameterValue.value = 3 ;

exportRequest.parameterValues.push(parameterValue);

//Include parameters

var parameterValue = new dundas.data.SingleBooleanValue;

parameterValue.parameterId = dundas.constants.EXCEL_INCLUDE_PARAMETERS_ID;

parameterValue.value = true;

exportRequest.parameterValues.push(parameterValue);

//On the left

var parameterValue = new dundas.data.SingleNumberValue();

parameterValue.parameterId = dundas.constants.EXCEL_PARAMETER_VALUES_LOCATION_ID;

parameterValue.value = 2;

exportRequest.parameterValues.push(parameterValue);

//Append date to file name

var parameterValue = new dundas.data.SingleBooleanValue;

parameterValue.parameterId = dundas.constants.APPEND_DATE_TO_FILE_NAME_ID;

parameterValue.value = true;

exportRequest.parameterValues.push(parameterValue);

// Get the perform export promise.

var exportPromise =

exportService.performExport(exportRequest);

// Setup a loading dialog.

viewService.showLoadingRestCall(exportPromise);

exportPromise.done(

function(exportId)

          {

          // Get the Url for the export file.

          var exportFileUrl =

                         exportService.getExportResultUrl(exportId);

 

          // Force the browser to download the file.


  window.location.replace(exportFileUrl);

          }

);

I’d second Derek’s recommendation and just use Excel in this use case - for CSV exports, we don’t support the inclusion of parameter values (as a list beside/below/above the table) since CSV is basically just meant to be a raw dump of pure data. Excel exports, while a data dump in a lot of respects, is at least meant to be flexible enough to provide formatting considerations like this (especially for tables).