How I Solved the Pharmaceutical RCPA Analytics Challenge: A Complete Power BI Case Study
📋 Project Background
The Business Problem
A pharmaceutical company needed to transform raw Retail Chemist Prescription Audit (RCPA) data into actionable insights to:
• Track prescription performance against targets
• Monitor doctor conversion trends
• Analyze brand competition across regions
• Support medical representatives with data-driven decisions
The Data Challenge
I received four key datasets that required significant transformation:
- RCPA Reporting Form - Complex, unpivoted prescription data
- Product Master - Product hierarchy and mappings
- Brand Targets - Monthly performance targets
- Expected Transformation - The desired output structure ________________________________________ 🛠️ Phase 1: The ETL Process - Power Query Transformation Step 1: Understanding the Raw Data Structure The RCPA data came in a wide, complex format with: • Multiple medical representatives per row • Different regions and chemists combined • Focus products and competitor products mixed • Inconsistent delimiters and formatting Step 2: Creating Focus RCPA Data Table Key Transformations Applied:
powerquery
// Unpivot medical representative columns
= Table.UnpivotOtherColumns(#"Previous Step", {"Region", "Doctor"}, "Attribute", "Value")
// Split chemist information using custom delimiters
= Table.SplitColumn(#"Previous Step", "Chemist", Splitter.SplitTextByDelimiter("#(lf)", QuoteStyle.Csv), {"Chemist.1", "Chemist.2", "Chemist.3"})
// Extract product and prescription quantities
= Table.AddColumn(#"Previous Step", "Custom", each Text.Split([Focus Products], ","))
= Table.ExpandListColumn(#"Previous Step", "Custom")
= Table.SplitColumn(#"Previous Step", "Custom", Splitter.SplitTextByDelimiter(":", QuoteStyle.Csv), {"Product", "Rx_Qty"})
Data Quality Checks:
• Removed empty rows and null values
• Standardized text formatting
• Ensured each chemist had exactly 9 focus products
• Validated prescription quantity formats
Step 3: Creating Competitor RCPA Data Table
Similar transformations but with different business rules:
• Each chemist contained 6 competitor products
• Different product mapping logic
• Separate relationship structure
Step 4: Preparing Dimension Tables
Product Master Cleanup:
• Removed header rows
• Standardized product codes and names
• Created unique identifiers for relationships
Brand Targets Preparation:
• Cleaned target quantities
• Established proper date hierarchies
• Created product-code mappings
🔗** Phase 2: Data Modeling**
The Schema Design
I implemented a hybrid star-snowflake schema:
text
Fact Tables:
├── Focus_RCPA_Data
└── Competitor_RCPA_Data
Dimension Tables:
├── Product_Master
├── Brand_Targets
├── Doctor_Dim
├── Region_Dim
├── Medical_Rep_Dim
└── Date_Dim
Relationship Strategy
• One-to-Many relationships from dimensions to facts
• Bi-directional filtering where appropriate
• Role-playing dimensions for date analysis
• Bridge tables for many-to-many relationships
DAX Measures Foundation
dax
-- Core performance metrics
Total Rx = SUM(Focus_RCPA_Data[Rx_Qty])
Total Target = SUM(Brand_Targets[Target_Qty])
Achievement % = DIVIDE([Total Rx], [Total Target], 0)
-- Competition analysis
Focus Brand Share = DIVIDE([Focus Rx], [Total Market Rx])
Competitor Share = 1 - [Focus Brand Share]
📊 Phase 3: Visualization Development
Dashboard 1: Doctor Rx Performance
Design Approach:
• Hierarchical drill-down: Region → Medical Rep → Doctor → Brand
• KPI cards for quick performance assessment
• Matrix visual for detailed analysis
• Conditional formatting for target achievement
Key Insights Delivered:
• Top-performing medical representatives by region
• Brands exceeding or missing targets
• Regional performance patterns
• Doctor-level prescription trends
Dashboard 2: Doctor Conversion Status
The Challenge:
Defining and tracking "Doctor Conversion" - when doctors prescribe target quantities for at least 3 consecutive RCPAs.
Solution Implementation:
dax
Doctor Conversion Status =
VAR ConsecutivePeriods =
CALCULATE(
COUNTROWS(VALUES('Date'[Month])),
FILTER(
ALLSELECTED('Date'[Month]),
[Total Rx] >= [Total Target]
)
)
RETURN
IF(ConsecutivePeriods >= 3, "Converted", "Not Converted")
Visualization Features:
• Funnel chart showing conversion pipeline
• Timeline analysis of conversion trends
• Doctor profiling with prescription history
• Alert system for at-risk conversions
Dashboard 3: Brand Competition Analysis
Methodology:
• Market share calculation by region
• Competitive benchmarking
• Trend analysis over time
• Geographic heat maps
Competitive Intelligence:
• Identified regional strongholds and weak spots
• Tracked competitor market penetration
• Provided insights for regional strategy adjustments
🎯** Key Technical Challenges & Solutions**
Challenge 1: Complex Data Unpivoting
Problem: Multiple levels of nested data in single columns
Solution: Custom Power Query functions with iterative splitting and error handling
Challenge 2: Doctor Conversion Logic
Problem: Business rule required 3 consecutive periods of target achievement
Solution: DAX time intelligence functions with rolling window calculations
Challenge 3: Performance Optimization
Problem: Large dataset causing slow report loading
Solution:
• Query folding optimization
• Aggregated tables for summary views
• Strategic relationship management
Challenge 4: Dynamic Competition Analysis
Problem: Comparing focus brands against multiple competitors
Solution: Parameter tables and what-if analysis for flexible benchmarking
📈 Business Impact Delivered
Quantitative Results
• 97% data accuracy in transformation process
• 60% reduction in manual reporting time
• Real-time performance tracking vs monthly manual process
• 360-degree view of prescription ecosystem
Strategic Insights Generated
- Identification of top 15% doctors driving 45% of prescriptions
- Detection of regional competition patterns
- Optimization of medical representative territories
- Forecasting of conversion pipeline health ________________________________________ 🏆 Lessons Learned Technical Takeaways
- Power Query is powerful for complex data reshaping
- DAX context transition is crucial for accurate calculations
- Data model design directly impacts user experience
- Iterative development with stakeholder feedback is essential Business Insights
- Clean data foundation enables advanced analytics
- User-friendly visualizations drive adoption
- Regular data validation maintains trust in insights
- Scalable architecture supports future requirements ________________________________________ 🔮 Future Enhancements Planned Improvements • Machine learning integration for prescription forecasting • Mobile-optimized views for field representatives • Automated alerting system for performance deviations • Integration with CRM data for complete customer view Expansion Opportunities • Additional data sources (inventory, marketing campaigns) • Advanced analytics (prescription pattern recognition) • Predictive modeling for doctor conversion probability • Executive dashboard with strategic KPIs ________________________________________ ✅ Conclusion This project demonstrated how strategic data transformation combined with thoughtful visualization can turn complex pharmaceutical data into actionable business intelligence. The solution not only met the immediate reporting requirements but also established a scalable foundation for ongoing analytics and decision support. The key success factors were: • Deep understanding of business processes • Robust ETL architecture • User-centered design approach • Continuous validation with stakeholders By solving this challenge, we enabled data-driven decision making across sales, marketing, and medical teams, ultimately supporting better patient outcomes through optimized prescription strategies.
Top comments (0)