Reversing a semantic model w/ incremental refresh using Claude

Ever faced the issue of having to download a semantic model from the Power BI service but getting stuck when incremental refresh has been implemented?

Usually it’s a rule of thumb to keep the original .pbix file to allow for any modifications in Power BI Desktop, but sometimes that file is lost, misplaced or somehow no longer available. While there are some work arounds blogged out there I though I’d give Claude a test on converting a .bim file to a .pbip project. A .bim file is obtainable using Tabular Editor, which you can find as a free version here, or paid version here (additional features). Connect to the live semantic model and select Save As (model.bim).

Once the model.bim is on you computer, you can release Claude on it to convert it into a .pbip project that you can open and manage through Power BI Desktop.

NB!
Incremental refresh is to be re-configured once deployed to the service and a full refresh is required.

Below is the complete prompt that I had Claude generate once we were through some hiccups.

Property ‘datasetReference’ has not been defined and schema does not allow additional properties. Path ‘datasetReference’, line 3, position 21

Error Message:
Cannot read ‘C:\<path removed>\model.bim’. Missing required artifact ‘model.bim’.

DatasetDefinition: Required artifact is missing in ‘C:\<path removed>\definition.pbism’.

Only text with UTF8 encoding without BOM (byte order marks) is supported. Detected BOM: ‘UTF-8’

Prompt begin: Convert a .bim file into a .pbip (Power BI Project) structure.

Analyze the model.bim file

Given the model.bim file (SSAS Tabular / Power BI semantic model JSON), create a valid .pbip project that opens in Power BI Desktop. Follow these exact rules:

Folder structure

<ProjectName>.pbip
<ProjectName>.SemanticModel/
    .platform
    definition.pbism
    model.bim
<ProjectName>.Report/
    .platform
    definition.pbir

File contents

<ProjectName>.pbip

{
  "version": "1.0",
  "artifacts": [
    {
      "report": {
        "path": "<ProjectName>.Report"
      }
    }
  ],
  "settings": {
    "enableAutoRecovery": true
  }
}

<ProjectName>.SemanticModel/definition.pbism

{
  "version": "1.0",
  "settings": {}
}

<ProjectName>.SemanticModel/.platform

{
  "$schema": "https://developer.microsoft.com/json-schemas/fabric/gitIntegration/platformProperties/2.0.0/schema.json",
  "metadata": {
    "type": "SemanticModel",
    "displayName": "<ProjectName>"
  },
  "config": {
    "version": "2.0",
    "logicalId": "<generate-a-new-guid>"
  }
}

<ProjectName>.Report/definition.pbir

{
  "version": "4.0",
  "datasetReference": {
    "byPath": {
      "path": "../<ProjectName>.SemanticModel"
    },
    "byConnection": null
  }
}

<ProjectName>.Report/.platform

{
  "$schema": "https://developer.microsoft.com/json-schemas/fabric/gitIntegration/platformProperties/2.0.0/schema.json",
  "metadata": {
    "type": "Report",
    "displayName": "<ProjectName>"
  },
  "config": {
    "version": "2.0",
    "logicalId": "<generate-a-different-guid>"
  }
}

<ProjectName>.SemanticModel/model.bim — the original .bim file, placed here unchanged.

Critical rules

  1. model.bim goes directly in the <ProjectName>.SemanticModel/ folder — NOT in a definition/ subfolder. The definition/ subfolder is only for TMDL format.
  2. All files must be UTF-8 without BOM (no byte order mark). Use new System.Text.UTF8Encoding(false) or equivalent.
  3. definition.pbism must NOT contain a datasetReference property — that property belongs only in .pbir files. The .pbism schema only allows version and settings.
  4. definition.pbir must reference the SemanticModel via relative path using "byPath": { "path": "../<ProjectName>.SemanticModel" }.
  5. The .pbip file is the entry point — users double-click this to open in Power BI Desktop.
  6. The .platform files contain Fabric Git integration metadata. The logicalId GUIDs are placeholders that get regenerated on deployment.
  7. Derive <ProjectName> from the "name" property at the root of the .bim JSON.

If the model uses incremental refresh

If the .bim contains a table with refreshPolicy and policyRange partitions, and the goal is to convert to standard import mode:

  • Remove the refreshPolicy object from the table
  • Replace all policyRange partitions with a single "type": "m" partition containing the M query from the refreshPolicy.sourceExpression, but with the RangeStart/RangeEnd filter removed
  • Remove the RangeStart and RangeEnd tables from model.tables

Let me know in the comments if you find this useful, not working at all, or any experiences in between 🙂

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.