The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
Hi all. I am trying creating a simple JS utility that will loop through all my reports, every page in each report, and return the properties and data sources for each visual on the page. I have no issues with the code so far, even "models.ExportDataType.Summarized" is printing the correct data. However, when I trying to access the underlying data ("models.ExportDataType.Underlying") of a particular visual (which is already published and working), I am seeing the error attached in the screenshot:
The issue is that this error is not giving me any clue as to where I should start looking to investigate the matter. Have any of you dealt with any similar issues? Everything else in the code is working just as needed 😞
// SET UP (assuming const reportsList already exists above)
let loadedResolve, reportLoaded = new Promise((res, rej) => { loadedResolve = res; });
let renderedResolve, reportRendered = new Promise((res, rej) => { renderedResolve = res; });
models = window['powerbi-client'].models;
function embedPowerBIReport() {
let accessToken = EMBED_ACCESS_TOKEN;
let embedUrl = EMBED_URL;
let embedReportId = REPORT_ID;
let tokenType = TOKEN_TYPE;
let permissions = models.Permissions.All;
let config = {
type: 'report',
tokenType: tokenType == '0' ? models.TokenType.Aad : models.TokenType.Embed,
accessToken: accessToken,
embedUrl: embedUrl,
id: embedReportId,
permissions: permissions,
settings: {
panes: {
filters: {
visible: true
},
pageNavigation: {
visible: true
}
},
bars: {
statusBar: {
visible: true
}
}
}
};
let embedContainer = $('#embedContainer')[0];
report = powerbi.embed(embedContainer, config);
report.off("loaded");
report.on("loaded", function () {
loadedResolve();
report.off("loaded");
});
report.off("error");
report.on("error", function (event) {
console.log(event.detail);
});
report.off("rendered");
report.on("rendered", function () {
renderedResolve();
report.off("rendered");
});
}
embedPowerBIReport();
await reportLoaded;
await reportRendered; // Wait for the report to be rendered before trying anything
// PAGE and VISUAL details ----
(async () => {
try {
let reportLog = `Report: Test Report 1\n\n`;
const pages = [];
const pagesObj = await report.getPages();
reportLog += `Pages available:\n`;
pagesObj.forEach((page, index) => {
pages.push({ name: page.name, displayName: page.displayName });
reportLog += `${index + 1} - ${page.displayName} | ${page.name}\n`;
});
reportLog += `\n`;
// Iterate through each page
for (const [pageIndex, page] of pages.entries()) {
await report.setPage(page.name); // Set the page and update the log
reportLog += `Page ${pageIndex + 1}: ${page.displayName} | ${page.name}\n\n`;
const allPages = await report.getPages();
const activePage = allPages.find(p => p.isActive);
const visuals = await activePage.getVisuals();
// Iterate through each visual
for (const [visualIndex, visual] of visuals.entries()) {
reportLog += `${visualIndex + 1} - ${visual.title} | ${visual.type} | ${visual.name}\n`;
const filters = await visual.getFilters();
if (filters && filters.length > 0) {
for (const filter of filters) {
if (filter.target) {
const targetEntries = Object.entries(filter.target);
if (visual.name === 'a8bb2cb4609976b00ddd') {
const result = await visual.exportData(models.ExportDataType.Summarized);
console.log(result.data);
const result = await visual.exportData(models.ExportDataType.Underlying);
console.log(result.data);
}
const nonTableEntries = targetEntries.filter(([key]) => key !== "table");
const tableEntry = targetEntries.find(([key]) => key === "table");
nonTableEntries.forEach(([key, value]) => {
const capitalizedKey = key.charAt(0).toUpperCase() + key.slice(1);
reportLog += `----> ${capitalizedKey}: ${value}\n`;
});
if (tableEntry) {
const [tableKey, tableValue] = tableEntry;
const capitalizedTableKey = tableKey.charAt(0).toUpperCase() + tableKey.slice(1);
reportLog += `----> ${capitalizedTableKey}: ${tableValue}\n`;
}
}
}
} else {
reportLog += `----> no data\n`;
}
}
reportLog += `\n`;
}
console.log(reportLog);
} catch (error) {
console.error(error);
}
}) ();
Hi @yazdanb,
Could you please confirm if the issue has been resolved after raising a support case? If a solution has been found, it would be greatly appreciated if you could share your insights with the community. This would be helpful for other members who may encounter similar issues.
Thank you for your understanding and assistance.
Hi @yazdanb,
We are following up once again regarding your query. Could you please confirm if the issue has been resolved through the support ticket with Microsoft?
If the issue has been resolved, we kindly request you to share the resolution or key insights here to help others in the community. If we don’t hear back, we’ll go ahead and close this thread.
Should you need further assistance in the future, we encourage you to reach out via the Microsoft Fabric Community Forum and create a new thread. We’ll be happy to help.
Thank you for your understanding and participation.
If you have a Pro license you can open a Pro ticket at https://admin.powerplatform.microsoft.com/newsupportticket/powerbi
Otherwise you can raise an issue at https://community.fabric.microsoft.com/t5/Issues/idb-p/Issues .