I'm using the Power Bi Embedded API to show reports to my users in a web application.
The API has an exportData() method that is designed to export either the full data or the summarized data from a visual in the report.
My problem occurs when trying to export the summarized data:
myVisual.exportData(ExportDataType.Summarized);
when I do this, this is what I get back:
As you can see, the returned data has a TooFewFields error, with the message Too few fields: expected 3 fields but parsed 1.
Can anyone explain what this error means, and why it is happening? I tried googling, but didn't find anything regarding this particular error.
Note that:
The "TooFewFields" error occurred because, The ‘exportData()’ method mainly consists of 2 parameters Namely Summarized Datatype and Count of Rows to be returned. But the code that you have written does not consist the parameter as expected. You have to include Models. Exportdatatype. Summarized and the row count to get the required result.
Find the below code snippet:
1.Get the page which contains visual:
const pages = await report. getPages();
let page = pages.filter(function (page) {
return page.isActive
})[0];
const visuals = await page.getVisuals();
2 Find the target visual:
let visual = visuals.filter(function (visual) {
return visual.name === "Required_Visual_Name";
})[0];
3.Export data from visual:
const result = await visual.exportData(models.ExportDataType.Summarized,100);
console.log(result.data);
Output:
Please find the reference here for exporting summarized data: https://docs.microsoft.com/javascript/api/overview/powerbi/export-data