- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2025 11:29 AM
In JavaScript, the function is encodeURIComponent(). It automatically handles all special characters.
Here is how you would do it in code:
// 1. Define your base URL and report ID
const reportId = "fdc8576e-93b4-4865-ab57-4a918fadf991c"; // Your Report ID
const baseUrl = `https://app.powerbi.com/reportEmbed?reportId=${reportId}&autoAuth=true`;
// 2. Define your filter logic in a raw, unencoded string
// This value might come from a dropdown or search box on your web page
const resellerId = "[PartnerProId]"; // Example value
const rawFilter = `activation_actuals_forecast/ResellerID eq '${resellerId}'`;
// 3. Use encodeURIComponent() to encode ONLY the filter part
const encodedFilter = encodeURIComponent(rawFilter);
// 4. Assemble the final URL
// Note: We are NOT encoding the '$filter=' part, only the value that comes after it.
// The original issue also encoded the '$' ($ -> %24), which works, but it's more standard to encode only the value.
const finalUrl = `${baseUrl}&$filter=${encodedFilter}`;
// 5. Set the iframe source
const iframe = document.getElementById('reportIframe');
iframe.src=finalUrl;
console.log(finalUrl);
// Output will look like:
// https://app.powerbi.com/reportEmbed?reportId=...&autoAuth=true&$filter=activation_actuals_forecast%2...