-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Description
Problem
Currently, calling add-value-field on an OLAP PivotTable (connected to Data Model) always fails with:
Cannot add value field '[Measures].[Total ACR]' to OLAP PivotTable.
OLAP measures must be pre-defined in the Excel Data Model.
User's attempted workflow:
{
"action": "add-value-field",
"pivotTableName": "ACR_by_Date",
"fieldName": "[Measures].[Total ACR]",
"sessionId": "..."
}Why this is confusing for LLMs:
- ✅
add-value-fieldworks for regular PivotTables (range/table-based) - ❌
add-value-fieldalways fails for OLAP PivotTables (Data Model-based) - 🤔 LLMs have to learn two different workflows for the same conceptual operation
- 📚 Error message requires manual intervention (open Excel, create measure, etc.)
Proposed Solution
Make add-value-field smart enough to auto-create DAX measures for OLAP PivotTables:
- Detect if PivotTable is OLAP (Data Model-based)
- Auto-create DAX measure with appropriate aggregation function
- Add the measure to the PivotTable values area
- Return success
Benefits:
- ✅ Single unified API - LLMs don't need to detect PivotTable type
- ✅ "It just works" - no confusing error messages
- ✅ Matches LLM mental model - "add this field as sum/count/average"
- ✅ Backward compatible - existing workflows continue working
Implementation Plan
1. In OlapPivotTableFieldStrategy.AddValueField():
// When adding value field to OLAP PivotTable:
// 1. Extract table name and field name from the field reference
// 2. Check if DAX measure already exists (optional - avoid duplicates)
// 3. Auto-create DAX measure based on aggregation function:
// - Sum → [FieldName Sum] = SUM('TableName'[FieldName])
// - Count → [FieldName Count] = COUNT('TableName'[FieldName])
// - Average → [FieldName Average] = AVERAGE('TableName'[FieldName])
// - etc.
// 4. Add the new measure to PivotTable values area
// 5. Return success2. Test Coverage
- ✅ Regular PivotTable + add-value-field (already works)
- ✅ OLAP PivotTable + add-value-field with Sum (new - auto-create DAX)
- ✅ OLAP PivotTable + add-value-field with Count (new - auto-create DAX)
- ✅ OLAP PivotTable + add-value-field with pre-existing measure (should still work)
3. Documentation Updates
- Update
excel_pivottable.mdprompt: Remove limitation warning - Update tool description: Clarify auto-DAX behavior
- Update examples: Show OLAP PivotTable workflows
Alternative Considered (Rejected)
Option: Separate excel_olap_pivottable tool
- ❌ More confusing for LLMs (two APIs for same operation)
- ❌ More documentation to maintain
- ❌ Requires LLMs to detect PivotTable type first
Impact
Before:
- LLMs get error message and must use manual workaround
- Different workflows for regular vs OLAP PivotTables
After:
- LLMs use same
add-value-fieldaction for all PivotTable types - DAX measures auto-created behind the scenes
- Consistent, intuitive API
Definition of Done
- Failing test case created (OLAP PivotTable + add-value-field)
- Implementation in
OlapPivotTableFieldStrategy.AddValueField() - Test passes after implementation
- Additional test cases for Count, Average, etc.
- Documentation updated (prompt files, tool descriptions)
- Integration test with end-to-end workflow
- PR created and reviewed
Metadata
Metadata
Assignees
Labels
No labels