Change one Tableau KPI without changing the whole workbook: a cwtwb example
Description and use
Clone a Tableau KPI worksheet and replace Sales with Profit using the cwtwb Python SDK, keeping the original worksheet unchanged.
Problem
Need a Profit version of a Sales KPI while keeping the original Sales view functional.
Outcome
The cloned worksheet now uses Profit in all calculations, while the original Sales worksheet remains intact.
Workflow
- Open existing workbook with TWBEditor
- Clone worksheet "1. KPI" to "1. KPI Profit"
- Apply worksheet refactor mapping {"Sales":"Profit"}
- Set the new worksheet visible
- Save the modified workbook
Evidence
The checked‑in example opens 5 KPI Design Ideas (2).twb, copies the worksheet 1. KPI to 1. KPI Profit, and applies the mapping Sales -> Profit to the copy.
The repository's worksheet‑refactor test checks that the original worksheet retains Sales formulas while the clone contains Profit formulas.
Before using the output in production, open it in Tableau, review the KPI values and labels, exercise relevant filters and dates, and compare the unaffected views with the original workbook.
- Record date: 2026-10-10T02:56:12.862Z