{
  "nbformat": 4,
  "nbformat_minor": 5,
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "name": "python",
      "version": "3.13.0"
    },
    "blog_metadata": {
      "topic": "Power BI’s R and Python Visuals Retirement: The Migration Choices Analytics Teams Need Now",
      "slug": "power-bi-s-r-and-python-visuals-retirement-the-migration-cho",
      "generated_by": "LinkedIn Post Generator + Azure OpenAI",
      "generated_at": "2026-11-11T21:10:02.925Z"
    }
  },
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "# Power BI’s R and Python Visuals Retirement: The Migration Choices Analytics Teams Need Now\n",
        "\n",
        "This notebook turns the blog post into a hands-on validation workflow. The focus is not chart parity, but portfolio risk: inventory scripted dependencies, score migration priority, recommend destination patterns, and summarize a migration backlog.\n",
        "\n",
        "The examples below use small in-memory datasets so you can validate the operating model quickly before applying it to real Power BI metadata exports."
      ]
    },
    {
      "cell_type": "code",
      "metadata": {},
      "source": [
        "%pip install pandas matplotlib seaborn"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {},
      "source": [
        "import pandas as pd\n",
        "from io import StringIO\n",
        "import matplotlib.pyplot as plt\n",
        "import seaborn as sns\n",
        "\n",
        "pd.set_option('display.max_columns', None)\n",
        "pd.set_option('display.width', 120)\n",
        "sns.set_theme(style='whitegrid')"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Operating model overview\n",
        "\n",
        "The blog argues for a disciplined migration flow: start from maintained metadata, identify R/Python dependencies, score priority, choose a destination pattern, and manage the work as a backlog. The diagram below recreates that flow in Python so it can run directly in a notebook."
      ]
    },
    {
      "cell_type": "code",
      "metadata": {},
      "source": [
        "from matplotlib.patches import FancyBboxPatch\n",
        "\n",
        "fig, ax = plt.subplots(figsize=(14, 7))\n",
        "ax.set_xlim(0, 14)\n",
        "ax.set_ylim(0, 10)\n",
        "ax.axis('off')\n",
        "\n",
        "def box(x, y, w, h, text, fc='#E8F1FB', ec='#4C78A8', fontsize=10):\n",
        "    patch = FancyBboxPatch((x, y), w, h, boxstyle='round,pad=0.02,rounding_size=0.08',\n",
        "                           linewidth=1.5, edgecolor=ec, facecolor=fc)\n",
        "    ax.add_patch(patch)\n",
        "    ax.text(x + w/2, y + h/2, text, ha='center', va='center', fontsize=fontsize)\n",
        "\n",
        "box(0.5, 7.8, 2.4, 1.0, 'Maintained\\nmetadata export')\n",
        "box(3.4, 7.8, 2.2, 1.0, 'Inventory\\npipeline')\n",
        "box(6.2, 7.7, 2.2, 1.2, 'R/Python\\ndependency?')\n",
        "box(9.0, 8.6, 2.4, 0.9, 'Score migration\\npriority', fc='#FDECC8', ec='#DD8452')\n",
        "box(9.0, 6.8, 2.4, 0.9, 'Track as\\nunaffected', fc='#EAF7EA', ec='#55A868')\n",
        "box(12.0, 8.6, 1.6, 0.9, 'Choose\\nmigration\\npath', fc='#FDECC8', ec='#DD8452', fontsize=9)\n",
        "box(11.6, 6.9, 2.2, 0.8, 'Migration backlog', fc='#F7E8F6', ec='#B279A2')\n",
        "box(11.2, 5.5, 2.8, 0.7, 'Rebuild in native Power BI', fc='#FFF4D6', ec='#C9A227', fontsize=9)\n",
        "box(11.2, 4.5, 2.8, 0.7, 'Move logic to Fabric / notebooks', fc='#FFF4D6', ec='#C9A227', fontsize=9)\n",
        "box(11.2, 3.5, 2.8, 0.7, 'External app or embedded analytics', fc='#FFF4D6', ec='#C9A227', fontsize=9)\n",
        "box(11.2, 2.5, 2.8, 0.7, 'Retire low-value report', fc='#FFF4D6', ec='#C9A227', fontsize=9)\n",
        "\n",
        "arrow = dict(arrowstyle='->', lw=1.8, color='#444444')\n",
        "ax.annotate('', xy=(3.4, 8.3), xytext=(2.9, 8.3), arrowprops=arrow)\n",
        "ax.annotate('', xy=(6.2, 8.3), xytext=(5.6, 8.3), arrowprops=arrow)\n",
        "ax.annotate('', xy=(9.0, 9.05), xytext=(8.4, 8.75), arrowprops=arrow)\n",
        "ax.annotate('', xy=(9.0, 7.25), xytext=(8.4, 7.85), arrowprops=arrow)\n",
        "ax.annotate('', xy=(12.0, 9.05), xytext=(11.4, 9.05), arrowprops=arrow)\n",
        "ax.annotate('', xy=(11.6, 7.3), xytext=(10.2, 8.6), arrowprops=arrow)\n",
        "for y in [5.85, 4.85, 3.85, 2.85]:\n",
        "    ax.annotate('', xy=(12.6, y + 0.35), xytext=(12.8, 8.6), arrowprops=dict(arrowstyle='->', lw=1.2, color='#666666'))\n",
        "\n",
        "ax.text(8.65, 8.95, 'Yes', fontsize=10)\n",
        "ax.text(8.65, 7.0, 'No', fontsize=10)\n",
        "ax.set_title('Migration operating model for retiring R/Python visuals', fontsize=14)\n",
        "plt.show()"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Example 1: Flag obvious R/Python visual dependencies\n",
        "\n",
        "This first-pass inventory is intentionally simple. It reads a maintained metadata export, marks visuals whose type indicates an R or Python dependency, and produces a shortlist of reports and pages to investigate."
      ]
    },
    {
      "cell_type": "code",
      "metadata": {},
      "source": [
        "# Load a maintained metadata export and flag R/Python visual dependencies\n",
        "import pandas as pd\n",
        "from io import StringIO\n",
        "\n",
        "csv_text = \"\"\"workspace,report,visual_id,visual_type,page,owner,view_count,refresh_failures,business_criticality\n",
        "Finance,Executive KPI,v1,pythonVisual,Summary,alex,420,1,5\n",
        "Finance,Executive KPI,v2,barChart,Summary,alex,420,1,5\n",
        "Sales,Pipeline Review,v3,rVisual,Forecast,jamie,180,3,4\n",
        "HR,Headcount Trends,v4,lineChart,Overview,taylor,75,0,3\n",
        "\"\"\"\n",
        "\n",
        "df = pd.read_csv(StringIO(csv_text))\n",
        "script_types = {\"pythonVisual\", \"rVisual\"}\n",
        "df[\"has_script_visual\"] = df[\"visual_type\"].isin(script_types)\n",
        "flagged = df[df[\"has_script_visual\"]][\n",
        "    [\"workspace\", \"report\", \"visual_id\", \"visual_type\", \"page\"]\n",
        "]\n",
        "\n",
        "print(flagged.to_string(index=False))"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Example 2: Score migration priority\n",
        "\n",
        "Once dependencies are identified, the next step is triage. This example creates a lightweight priority score using business criticality, usage, and refresh failures so teams can separate dangerous dependencies from merely annoying ones."
      ]
    },
    {
      "cell_type": "code",
      "metadata": {},
      "source": [
        "# Calculate a simple migration-priority score for reports with R/Python dependencies\n",
        "import pandas as pd\n",
        "\n",
        "data = [\n",
        "    {\"workspace\": \"Finance\", \"report\": \"Executive KPI\", \"visual_type\": \"pythonVisual\", \"view_count\": 420, \"refresh_failures\": 1, \"business_criticality\": 5},\n",
        "    {\"workspace\": \"Sales\", \"report\": \"Pipeline Review\", \"visual_type\": \"rVisual\", \"view_count\": 180, \"refresh_failures\": 3, \"business_criticality\": 4},\n",
        "    {\"workspace\": \"HR\", \"report\": \"Headcount Trends\", \"visual_type\": \"lineChart\", \"view_count\": 75, \"refresh_failures\": 0, \"business_criticality\": 3},\n",
        "]\n",
        "\n",
        "df = pd.DataFrame(data)\n",
        "df = df[df[\"visual_type\"].isin([\"pythonVisual\", \"rVisual\"])].copy()\n",
        "df[\"priority_score\"] = (\n",
        "    df[\"business_criticality\"] * 10\n",
        "    + (df[\"view_count\"] / 25).round().astype(int)\n",
        "    + df[\"refresh_failures\"] * 5\n",
        ")\n",
        "df[\"priority_band\"] = pd.cut(\n",
        "    df[\"priority_score\"], bins=[0, 25, 45, 999], labels=[\"Low\", \"Medium\", \"High\"]\n",
        ")\n",
        "\n",
        "print(df[[\"report\", \"visual_type\", \"priority_score\", \"priority_band\"]].to_string(index=False))"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Example 3: Visualize the priority scores\n",
        "\n",
        "A simple chart makes the triage easier to discuss with stakeholders. This cell plots the scored reports and colors them by priority band."
      ]
    },
    {
      "cell_type": "code",
      "metadata": {},
      "source": [
        "import pandas as pd\n",
        "import matplotlib.pyplot as plt\n",
        "import seaborn as sns\n",
        "\n",
        "scored = pd.DataFrame([\n",
        "    {\"report\": \"Executive KPI\", \"visual_type\": \"pythonVisual\", \"view_count\": 420, \"refresh_failures\": 1, \"business_criticality\": 5},\n",
        "    {\"report\": \"Pipeline Review\", \"visual_type\": \"rVisual\", \"view_count\": 180, \"refresh_failures\": 3, \"business_criticality\": 4},\n",
        "])\n",
        "scored[\"priority_score\"] = (\n",
        "    scored[\"business_criticality\"] * 10\n",
        "    + (scored[\"view_count\"] / 25).round().astype(int)\n",
        "    + scored[\"refresh_failures\"] * 5\n",
        ")\n",
        "scored[\"priority_band\"] = pd.cut(\n",
        "    scored[\"priority_score\"], bins=[0, 25, 45, 999], labels=[\"Low\", \"Medium\", \"High\"]\n",
        ")\n",
        "\n",
        "plt.figure(figsize=(8, 4))\n",
        "sns.barplot(data=scored, x=\"report\", y=\"priority_score\", hue=\"priority_band\", dodge=False, palette={\"Low\": \"#55A868\", \"Medium\": \"#DD8452\", \"High\": \"#C44E52\"})\n",
        "plt.title(\"Migration priority for scripted visual dependencies\")\n",
        "plt.xlabel(\"Report\")\n",
        "plt.ylabel(\"Priority score\")\n",
        "plt.legend(title=\"Priority band\")\n",
        "plt.tight_layout()\n",
        "plt.show()"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Example 4: Recommend a migration path\n",
        "\n",
        "After scoring, teams still need a destination pattern. This rule-based example maps each flagged report to a starting recommendation such as native Power BI, Fabric/notebooks, or retirement."
      ]
    },
    {
      "cell_type": "code",
      "metadata": {},
      "source": [
        "# Map each flagged report to a migration recommendation based on simple rules\n",
        "import pandas as pd\n",
        "\n",
        "df = pd.DataFrame([\n",
        "    {\"report\": \"Executive KPI\", \"visual_type\": \"pythonVisual\", \"priority_score\": 62, \"business_criticality\": 5},\n",
        "    {\"report\": \"Pipeline Review\", \"visual_type\": \"rVisual\", \"priority_score\": 47, \"business_criticality\": 4},\n",
        "    {\"report\": \"Legacy Sandbox\", \"visual_type\": \"pythonVisual\", \"priority_score\": 18, \"business_criticality\": 1},\n",
        "])\n",
        "\n",
        "def recommend_path(row: pd.Series) -> str:\n",
        "    if row[\"priority_score\"] >= 55:\n",
        "        return \"Rebuild in native Power BI first\"\n",
        "    if row[\"visual_type\"] == \"rVisual\":\n",
        "        return \"Evaluate Fabric notebook or externalized analytics\"\n",
        "    if row[\"business_criticality\"] <= 2:\n",
        "        return \"Retire or consolidate\"\n",
        "    return \"Prototype replacement and validate with users\"\n",
        "\n",
        "df[\"migration_path\"] = df.apply(recommend_path, axis=1)\n",
        "print(df.to_string(index=False))"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Example 5: Summarize the migration backlog\n",
        "\n",
        "Stakeholder communication should stay concise: priority, owner, path, and count. This example groups a small backlog into a summary table suitable for status reviews."
      ]
    },
    {
      "cell_type": "code",
      "metadata": {},
      "source": [
        "# Produce a concise migration backlog summary for stakeholder communication\n",
        "import pandas as pd\n",
        "\n",
        "backlog = pd.DataFrame([\n",
        "    {\"report\": \"Executive KPI\", \"owner\": \"alex\", \"priority_band\": \"High\", \"migration_path\": \"Rebuild in native Power BI first\"},\n",
        "    {\"report\": \"Pipeline Review\", \"owner\": \"jamie\", \"priority_band\": \"High\", \"migration_path\": \"Evaluate Fabric notebook or externalized analytics\"},\n",
        "    {\"report\": \"Legacy Sandbox\", \"owner\": \"sam\", \"priority_band\": \"Low\", \"migration_path\": \"Retire or consolidate\"},\n",
        "])\n",
        "\n",
        "summary = backlog.groupby([\"priority_band\", \"migration_path\"]).size().reset_index(name=\"count\")\n",
        "print(summary.to_string(index=False))"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Example 6: Portfolio view by destination pattern\n",
        "\n",
        "This optional visualization turns the backlog into a portfolio view. It helps teams see whether the estate is trending toward native rebuilds, notebook relocation, or retirement."
      ]
    },
    {
      "cell_type": "code",
      "metadata": {},
      "source": [
        "import pandas as pd\n",
        "import matplotlib.pyplot as plt\n",
        "\n",
        "backlog = pd.DataFrame([\n",
        "    {\"report\": \"Executive KPI\", \"owner\": \"alex\", \"priority_band\": \"High\", \"migration_path\": \"Rebuild in native Power BI first\"},\n",
        "    {\"report\": \"Pipeline Review\", \"owner\": \"jamie\", \"priority_band\": \"High\", \"migration_path\": \"Evaluate Fabric notebook or externalized analytics\"},\n",
        "    {\"report\": \"Legacy Sandbox\", \"owner\": \"sam\", \"priority_band\": \"Low\", \"migration_path\": \"Retire or consolidate\"},\n",
        "    {\"report\": \"Ops Daily\", \"owner\": \"morgan\", \"priority_band\": \"Medium\", \"migration_path\": \"Prototype replacement and validate with users\"},\n",
        "])\n",
        "\n",
        "counts = backlog[\"migration_path\"].value_counts().reset_index()\n",
        "counts.columns = [\"migration_path\", \"count\"]\n",
        "\n",
        "plt.figure(figsize=(9, 4))\n",
        "plt.barh(counts[\"migration_path\"], counts[\"count\"], color=\"#4C78A8\")\n",
        "plt.title(\"Backlog by recommended migration path\")\n",
        "plt.xlabel(\"Count\")\n",
        "plt.ylabel(\"Migration path\")\n",
        "plt.tight_layout()\n",
        "plt.show()"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Readiness self-assessment\n",
        "\n",
        "The blog closes with a practical question: how ready is your team? Use the simple rubric below to rate current scripted-visual migration readiness from 1 to 5."
      ]
    },
    {
      "cell_type": "code",
      "metadata": {},
      "source": [
        "readiness = pd.DataFrame([\n",
        "    {\"score\": 1, \"description\": \"No inventory, unknown dependencies, no owners, ad hoc support\"},\n",
        "    {\"score\": 2, \"description\": \"Partial awareness of scripted visuals, limited evidence, inconsistent ownership\"},\n",
        "    {\"score\": 3, \"description\": \"Basic inventory exists, critical reports identified, initial triage underway\"},\n",
        "    {\"score\": 4, \"description\": \"Priority scoring, destination patterns, and backlog management are in place\"},\n",
        "    {\"score\": 5, \"description\": \"Governed migration program with evidence, owners, testing, and supported runtime paths\"},\n",
        "])\n",
        "\n",
        "print(readiness.to_string(index=False))"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Next Steps\n",
        "\n",
        "- Freeze net-new use of retiring R/Python visuals.\n",
        "- Export and preserve evidence for workspaces, reports, pages, and visuals.\n",
        "- Flag scripted dependencies and score them by criticality, usage, and operational pain.\n",
        "- Force each dependency into one of four paths: retire, simplify, replace inside Power BI, or relocate outside the canvas.\n",
        "- Validate critical replacements with named business owners and explicit acceptance criteria.\n",
        "\n",
        "The key takeaway is that success is not visual parity. Success is a smaller, supportable analytics estate with explicit ownership and governed runtime paths."
      ]
    }
  ]
}