<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Embed - save copy report - data change impact in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Embed-save-copy-report-data-change-impact/m-p/4412251#M59516</link>
    <description>&lt;P&gt;fantastic response, thank you!&lt;BR /&gt;We do use a view layer to further reduce impact however on occassion it will still happen. If you could provide a script to automate i would be delighted!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-Rob&lt;/P&gt;</description>
    <pubDate>Sat, 15 Feb 2025 22:27:25 GMT</pubDate>
    <dc:creator>rdumont</dc:creator>
    <dc:date>2025-02-15T22:27:25Z</dc:date>
    <item>
      <title>Embed - save copy report - data change impact</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Embed-save-copy-report-data-change-impact/m-p/4412163#M59514</link>
      <description>&lt;P&gt;Hello, we use Power BI Embed and allow users to save copies of reports. Works great until the semantic model changes, table name change, column name change, etc.&lt;/P&gt;&lt;P&gt;Any user defined reports that refer to the table and/or columns that had a name change no longer work. We have multiple customers so this escalates quickly.&lt;BR /&gt;We do our best to minimize this from happening but occassinally it is unavoidable, is there a way to programatically detect the impact in advance and/or automatically apply the updated table/column name changes in user defined reports?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-Rob&lt;/P&gt;</description>
      <pubDate>Sat, 15 Feb 2025 14:30:51 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Embed-save-copy-report-data-change-impact/m-p/4412163#M59514</guid>
      <dc:creator>rdumont</dc:creator>
      <dc:date>2025-02-15T14:30:51Z</dc:date>
    </item>
    <item>
      <title>Re: Embed - save copy report - data change impact</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Embed-save-copy-report-data-change-impact/m-p/4412225#M59515</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="88292" data-lia-user-login="rdumont" class="lia-mention lia-mention-user"&gt;rdumont&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Power BI Embedded users face report breakage when table or column names change in the semantic model. To prevent this, schema changes must be detected in advance and reports updated automatically.&lt;/P&gt;
&lt;P&gt;Using the Power BI REST API, dataset schema can be extracted and compared with previous versions to detect changes. The Get Dataset Tables API fetches table and column structures:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;GET https://api.powerbi.com/v1.0/myorg/datasets/{datasetId}/tables
Authorization: Bearer {access_token}
&lt;/LI-CODE&gt;
&lt;P&gt;For deeper analysis in Premium/PPU workspaces, XMLA Endpoint DMV queries provide metadata:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;SELECT * FROM $System.TMSCHEMA_COLUMNS
&lt;/LI-CODE&gt;
&lt;P&gt;Once changes are detected, user reports can be updated by exporting the report JSON, replacing outdated references, and re-importing it:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;GET https://api.powerbi.com/v1.0/myorg/reports/{reportId}/export
&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;POST https://api.powerbi.com/v1.0/myorg/reports/import
Authorization: Bearer {access_token}
Content-Type: application/json
{
    "name": "Updated Report",
    "file": "{modified_json_report}"
}
&lt;/LI-CODE&gt;
&lt;P&gt;A more seamless approach is using SQL views to maintain column aliases or creating duplicate calculated columns with old names before renaming. Automating schema checks and report updates ensures minimal user impact. Let me know if you’d like a script to automate this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best regards,&lt;/P&gt;</description>
      <pubDate>Sat, 15 Feb 2025 17:00:40 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Embed-save-copy-report-data-change-impact/m-p/4412225#M59515</guid>
      <dc:creator>DataNinja777</dc:creator>
      <dc:date>2025-02-15T17:00:40Z</dc:date>
    </item>
    <item>
      <title>Re: Embed - save copy report - data change impact</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Embed-save-copy-report-data-change-impact/m-p/4412251#M59516</link>
      <description>&lt;P&gt;fantastic response, thank you!&lt;BR /&gt;We do use a view layer to further reduce impact however on occassion it will still happen. If you could provide a script to automate i would be delighted!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-Rob&lt;/P&gt;</description>
      <pubDate>Sat, 15 Feb 2025 22:27:25 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Embed-save-copy-report-data-change-impact/m-p/4412251#M59516</guid>
      <dc:creator>rdumont</dc:creator>
      <dc:date>2025-02-15T22:27:25Z</dc:date>
    </item>
    <item>
      <title>Re: Embed - save copy report - data change impact</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Embed-save-copy-report-data-change-impact/m-p/4412308#M59518</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="88292" data-lia-user-login="rdumont" class="lia-mention lia-mention-user"&gt;rdumont&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The best approach to prevent Power BI Embedded reports from breaking due to schema changes is to automate schema detection and report updates. Using the Power BI REST API, you can extract dataset schema and compare it with previous versions to detect renamed or deleted tables and columns. This can be done using the API endpoint:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;GET https://api.powerbi.com/v1.0/myorg/datasets/{datasetId}/tables
Authorization: Bearer {access_token}
&lt;/LI-CODE&gt;
&lt;P&gt;For Premium or PPU workspaces, XMLA Endpoint DMV queries provide deeper metadata insights:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;SELECT * FROM $System.TMSCHEMA_COLUMNS
&lt;/LI-CODE&gt;
&lt;P&gt;Once schema changes are detected, user reports can be updated by exporting the report JSON, replacing outdated references, and re-importing it. The export and import operations are performed using the following API endpoints:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;GET https://api.powerbi.com/v1.0/myorg/reports/{reportId}/export
Authorization: Bearer {access_token}
&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;POST https://api.powerbi.com/v1.0/myorg/reports/import
Authorization: Bearer {access_token}
Content-Type: application/json
{
    "name": "Updated Report",
    "file": "{modified_json_report}"
}
&lt;/LI-CODE&gt;
&lt;P&gt;A Python script can automate this process by retrieving the dataset schema, storing previous versions, detecting changes, and updating reports accordingly. The script starts by authenticating with Power BI and fetching the dataset schema:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;import requests
import json

TENANT_ID = "your-tenant-id"
CLIENT_ID = "your-client-id"
CLIENT_SECRET = "your-client-secret"
WORKSPACE_ID = "your-workspace-id"
DATASET_ID = "your-dataset-id"

AUTH_URL = f"https://login.microsoftonline.com/{TENANT_ID}/oauth2/v2.0/token"

def get_access_token():
    data = {
        "grant_type": "client_credentials",
        "client_id": CLIENT_ID,
        "client_secret": CLIENT_SECRET,
        "scope": "https://graph.microsoft.com/.default",
        "resource": "https://analysis.windows.net/powerbi/api"
    }
    headers = {"Content-Type": "application/x-www-form-urlencoded"}
    response = requests.post(AUTH_URL, data=data, headers=headers)
    return response.json().get("access_token")

def get_dataset_schema():
    headers = {"Authorization": f"Bearer {get_access_token()}"}
    response = requests.get(f"https://api.powerbi.com/v1.0/myorg/datasets/{DATASET_ID}/tables", headers=headers)
    return response.json()
&lt;/LI-CODE&gt;
&lt;P&gt;This schema is compared with a stored previous version to detect renamed tables and columns. If changes are detected, the script exports affected reports, modifies table/column references, and re-imports the updated reports:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;def export_report(report_id):
    headers = {"Authorization": f"Bearer {get_access_token()}"}
    response = requests.get(f"https://api.powerbi.com/v1.0/myorg/reports/{report_id}/export", headers=headers)
    return response.json()

def update_report_json(report_json, changes):
    updated_json = json.dumps(report_json)
    for old_table, new_table in changes["renamed_tables"].items():
        updated_json = updated_json.replace(old_table, new_table)
    for table, col_map in changes["renamed_columns"].items():
        for old_col, new_col in col_map.items():
            updated_json = updated_json.replace(old_col, new_col)
    return json.loads(updated_json)

def import_report(updated_json, report_name):
    headers = {
        "Authorization": f"Bearer {get_access_token()}",
        "Content-Type": "application/json"
    }
    data = {"name": report_name, "file": json.dumps(updated_json)}
    response = requests.post("https://api.powerbi.com/v1.0/myorg/reports/import", headers=headers, json=data)
    return response.status_code
&lt;/LI-CODE&gt;
&lt;P&gt;By automating schema monitoring and report updates, user impact can be minimized when unavoidable table or column name changes occur. Additionally, using SQL views or calculated columns with old names can help maintain stability. Let me know if you need further refinements or additional features like email notifications or Power Automate integration.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best regards,&lt;/P&gt;</description>
      <pubDate>Sun, 16 Feb 2025 02:09:29 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Embed-save-copy-report-data-change-impact/m-p/4412308#M59518</guid>
      <dc:creator>DataNinja777</dc:creator>
      <dc:date>2025-02-16T02:09:29Z</dc:date>
    </item>
  </channel>
</rss>

