export function badDataCostQuiz(form: FormTs) {
form.setTitle(() => '📊 How Much Is Bad Data Costing Your Business?');
// ============ CALCULATION STATE ============
const inputs = form.state<Record<string, number>>({
employees: 50,
avgSalary: 60000,
dataHoursWeek: 10,
errorRate: 15,
recordCount: 10000,
duplicateRate: 8,
decayRate: 25
});
const updateInput = (key: string, value: number) => {
inputs.update(current => ({ ...current, [key]: value }));
};
// ============ CALCULATIONS ============
const getEmployeesUsingData = () => Math.round((inputs().employees || 50) * 0.6);
const getHourlyCost = () => (inputs().avgSalary || 60000) / 2080;
const getWeeklyDataHours = () => inputs().dataHoursWeek || 10;
const getErrorRate = () => (inputs().errorRate || 15) / 100;
const getDuplicateRate = () => (inputs().duplicateRate || 8) / 100;
const getDecayRate = () => (inputs().decayRate || 25) / 100;
// Time wasted on bad data (hours/year per employee)
const getTimeWastedPerEmployee = () => {
const weeklyHours = getWeeklyDataHours();
const errorRate = getErrorRate();
return weeklyHours * errorRate * 52; // hours per year
};
// Total time cost
const getTotalTimeCost = () => {
const employees = getEmployeesUsingData();
const hoursWasted = getTimeWastedPerEmployee();
const hourlyRate = getHourlyCost();
return Math.round(employees * hoursWasted * hourlyRate);
};
// Duplicate record cost
const getDuplicateCost = () => {
const records = inputs().recordCount || 10000;
const duplicateRate = getDuplicateRate();
const costPerDuplicate = 10; // industry average
return Math.round(records * duplicateRate * costPerDuplicate);
};
// Decision cost (bad decisions from bad data)
const getDecisionCost = () => {
const baseCost = getTotalTimeCost();
return Math.round(baseCost * 0.3); // 30% additional cost from poor decisions
};
// Customer impact cost
const getCustomerImpactCost = () => {
const records = inputs().recordCount || 10000;
const decayRate = getDecayRate();
const impactPerRecord = 5;
return Math.round(records * decayRate * impactPerRecord);
};
// Total annual cost
const getTotalAnnualCost = () => {
return getTotalTimeCost() + getDuplicateCost() + getDecisionCost() + getCustomerImpactCost();
};
// Potential savings with clean data
const getPotentialSavings = () => Math.round(getTotalAnnualCost() * 0.7);
// Format currency
const formatCurrency = (value: number) => {
return new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD', maximumFractionDigits: 0 }).format(value);
};
// ============ COMPLETION SCREEN ============
form.configureCompletionScreen({
type: 'text',
title: () => `Bad Data Costs You ${formatCurrency(getTotalAnnualCost())}/Year`,
message: () => `You could save ${formatCurrency(getPotentialSavings())} annually by improving data quality. Download your detailed cost breakdown and ROI analysis.`
});
// ============ PAGES SETUP ============
const pages = form.addPages('quiz-pages', { heightMode: 'current-page' });
// ============ PAGE 1: Company Profile ============
const page1 = pages.addPage('company-profile', { mobileBreakpoint: 500 });
page1.addRow(row => {
row.addTextPanel('header1', {
label: 'Step 1 of 4: Company Profile',
computedValue: () => 'Tell us about your organization to calculate data quality costs',
customStyles: { fontSize: '0.9rem', color: '#6b7280', marginBottom: '1rem' }
});
});
page1.addSpacer({ height: '24px' });
page1.addRow(row => {
row.addSlider('employees', {
label: 'Total number of employees',
isRequired: true,
min: 10,
max: 1000,
step: 10,
defaultValue: 50,
showValue: true,
onValueChange: (val) => updateInput('employees', val || 50)
});
});
page1.addRow(row => {
row.addSlider('avgSalary', {
label: 'Average employee salary ($/year)',
isRequired: true,
min: 30000,
max: 200000,
step: 5000,
defaultValue: 60000,
showValue: true,
unit: '/year',
onValueChange: (val) => updateInput('avgSalary', val || 60000)
});
});
page1.addRow(row => {
row.addDropdown('industry', {
label: 'Industry',
isRequired: true,
options: [
{ id: 'finance', name: '🏦 Financial Services' },
{ id: 'healthcare', name: '🏥 Healthcare' },
{ id: 'retail', name: '🛒 Retail & E-commerce' },
{ id: 'tech', name: '💻 Technology' },
{ id: 'manufacturing', name: '🏭 Manufacturing' },
{ id: 'professional', name: '💼 Professional Services' },
{ id: 'other', name: '📦 Other' }
],
placeholder: 'Select your industry'
}, '1fr');
row.addDropdown('dataMaturity', {
label: 'Data Management Maturity',
tooltip: 'How sophisticated is your current data management?',
options: [
{ id: 'basic', name: 'Basic - spreadsheets & manual' },
{ id: 'developing', name: 'Developing - some automation' },
{ id: 'established', name: 'Established - CRM/ERP in place' },
{ id: 'advanced', name: 'Advanced - data governance' }
],
placeholder: 'Select maturity level'
}, '1fr');
});
// ============ PAGE 2: Data Usage ============
const page2 = pages.addPage('data-usage', { mobileBreakpoint: 500 });
page2.addRow(row => {
row.addTextPanel('header2', {
label: 'Step 2 of 4: Data Usage',
computedValue: () => 'How does your team interact with data?',
customStyles: { fontSize: '0.9rem', color: '#6b7280', marginBottom: '1rem' }
});
});
page2.addSpacer({ height: '24px' });
page2.addRow(row => {
row.addSlider('dataHoursWeek', {
label: 'Hours per week employees spend working with data',
isRequired: true,
min: 1,
max: 40,
step: 1,
defaultValue: 10,
showValue: true,
unit: 'hrs/week',
onValueChange: (val) => updateInput('dataHoursWeek', val || 10)
});
});
page2.addRow(row => {
row.addSlider('recordCount', {
label: 'Approximate number of customer/contact records',
isRequired: true,
min: 1000,
max: 500000,
step: 1000,
defaultValue: 10000,
showValue: true,
unit: 'records',
onValueChange: (val) => updateInput('recordCount', val || 10000)
});
});
page2.addRow(row => {
row.addSuggestionChips('dataSystems', {
label: 'What systems do you use for data? (select all)',
isRequired: true,
min: 1,
suggestions: [
{ id: 'crm', name: '📊 CRM (Salesforce, HubSpot)' },
{ id: 'erp', name: '🏢 ERP System' },
{ id: 'spreadsheets', name: '📑 Spreadsheets' },
{ id: 'marketing', name: '📧 Marketing Automation' },
{ id: 'analytics', name: '📈 Analytics Platform' },
{ id: 'custom', name: '🔧 Custom Database' }
]
});
});
// ============ PAGE 3: Data Quality Issues ============
const page3 = pages.addPage('data-quality', { mobileBreakpoint: 500 });
page3.addRow(row => {
row.addTextPanel('header3', {
label: 'Step 3 of 4: Data Quality Issues',
computedValue: () => 'What data problems does your organization face?',
customStyles: { fontSize: '0.9rem', color: '#6b7280', marginBottom: '1rem' }
});
});
page3.addSpacer({ height: '24px' });
page3.addRow(row => {
row.addSlider('errorRate', {
label: 'Estimated % of data that contains errors',
tooltip: 'Industry average is 10-25% for businesses without data governance',
isRequired: true,
min: 1,
max: 50,
step: 1,
defaultValue: 15,
showValue: true,
unit: '%',
onValueChange: (val) => updateInput('errorRate', val || 15)
});
});
page3.addRow(row => {
row.addSlider('duplicateRate', {
label: 'Estimated % of duplicate records',
tooltip: 'Industry average is 5-15% for CRM databases',
isRequired: true,
min: 1,
max: 30,
step: 1,
defaultValue: 8,
showValue: true,
unit: '%',
onValueChange: (val) => updateInput('duplicateRate', val || 8)
});
});
page3.addRow(row => {
row.addSlider('decayRate', {
label: 'Estimated % of data that becomes outdated annually',
tooltip: 'B2B data decays at ~25-30% per year on average',
isRequired: true,
min: 10,
max: 50,
step: 5,
defaultValue: 25,
showValue: true,
unit: '%/year',
onValueChange: (val) => updateInput('decayRate', val || 25)
});
});
page3.addRow(row => {
row.addCheckboxList('dataIssues', {
label: 'Which data quality issues do you experience?',
orientation: 'vertical',
options: [
{ id: 'incomplete', name: '🔲 Incomplete records (missing fields)' },
{ id: 'inconsistent', name: '🔀 Inconsistent formatting' },
{ id: 'outdated', name: '📅 Outdated information' },
{ id: 'duplicates', name: '👥 Duplicate entries' },
{ id: 'inaccurate', name: '❌ Inaccurate data' },
{ id: 'siloed', name: '🏝️ Data silos (disconnected systems)' }
]
});
});
// ============ PAGE 4: Results ============
const page4 = pages.addPage('results', { mobileBreakpoint: 500 });
page4.addRow(row => {
row.addTextPanel('header4', {
label: 'Step 4 of 4: Your Bad Data Cost Analysis',
computedValue: () => 'Here\'s what data quality issues are costing your business',
customStyles: { fontSize: '0.9rem', color: '#6b7280', marginBottom: '1rem' }
});
});
page4.addSpacer({ height: '24px' });
page4.addRow(row => {
row.addTextPanel('totalCost', {
label: '💸 Estimated Annual Cost of Bad Data',
computedValue: () => formatCurrency(getTotalAnnualCost()),
customStyles: {
fontSize: '2rem',
fontWeight: '800',
textAlign: 'center',
color: '#dc2626',
padding: '20px',
background: '#fef2f2',
borderRadius: '12px',
border: '3px solid #dc2626'
}
});
});
page4.addRow(row => {
row.addTextPanel('potentialSavings', {
label: '✅ Potential Annual Savings',
computedValue: () => formatCurrency(getPotentialSavings()),
customStyles: {
fontSize: '1.5rem',
fontWeight: '700',
textAlign: 'center',
color: '#059669',
padding: '15px',
background: '#ecfdf5',
borderRadius: '8px',
marginTop: '10px'
}
});
});
// Cost breakdown subform
const costBreakdown = page4.addSubform('costBreakdown', {
title: '📊 Cost Breakdown (click to expand)',
isCollapsible: true,
customStyles: { marginTop: '1rem', background: '#f9fafb', borderRadius: '8px' }
});
costBreakdown.addRow(row => {
row.addTextPanel('timeCost', {
label: '⏱️ Wasted Time Cost',
computedValue: () => formatCurrency(getTotalTimeCost()),
customStyles: { fontSize: '0.95rem', padding: '10px', background: '#dbeafe', borderRadius: '6px' }
}, '1fr');
row.addTextPanel('duplicateCostDisplay', {
label: '👥 Duplicate Records Cost',
computedValue: () => formatCurrency(getDuplicateCost()),
customStyles: { fontSize: '0.95rem', padding: '10px', background: '#fef3c7', borderRadius: '6px' }
}, '1fr');
});
costBreakdown.addRow(row => {
row.addTextPanel('decisionCost', {
label: '🎯 Poor Decision Cost',
computedValue: () => formatCurrency(getDecisionCost()),
customStyles: { fontSize: '0.95rem', padding: '10px', background: '#fee2e2', borderRadius: '6px' }
}, '1fr');
row.addTextPanel('customerCost', {
label: '👤 Customer Impact Cost',
computedValue: () => formatCurrency(getCustomerImpactCost()),
customStyles: { fontSize: '0.95rem', padding: '10px', background: '#f3e8ff', borderRadius: '6px' }
}, '1fr');
});
costBreakdown.addRow(row => {
row.addTextPanel('keyMetrics', {
computedValue: () => {
const hoursWasted = getTimeWastedPerEmployee() * getEmployeesUsingData();
return `Key Metrics: ${Math.round(hoursWasted).toLocaleString()} hours wasted/year • ${Math.round(getDuplicateRate() * 100)}% duplicate rate • ${Math.round(getDecayRate() * 100)}% annual decay`;
},
customStyles: {
fontSize: '0.85rem',
color: '#6b7280',
textAlign: 'center',
padding: '10px',
marginTop: '8px'
}
});
});
// ============ PAGE 5: Lead Capture ============
const page5 = pages.addPage('lead-capture', { mobileBreakpoint: 500 });
page5.addRow(row => {
row.addTextPanel('header5', {
label: 'Step 5 of 5: Get Your Full Report',
computedValue: () => 'Receive your detailed data quality cost analysis and improvement roadmap',
customStyles: { fontSize: '0.9rem', color: '#6b7280', marginBottom: '1rem' }
});
});
page5.addSpacer({ height: '24px' });
page5.addRow(row => {
row.addTextbox('name', { label: 'Your Name', isRequired: true, placeholder: 'John Smith' }, '1fr');
row.addEmail('email', { label: 'Work Email', isRequired: true, placeholder: 'john@company.com' }, '1fr');
});
page5.addRow(row => {
row.addTextbox('company', { label: 'Company Name', placeholder: 'Acme Inc.' }, '1fr');
row.addDropdown('role', {
label: 'Your Role',
options: [
{ id: 'data', name: 'Data Manager / Analyst' },
{ id: 'it', name: 'IT / Technical' },
{ id: 'operations', name: 'Operations' },
{ id: 'sales', name: 'Sales / Marketing' },
{ id: 'executive', name: 'Executive / Owner' },
{ id: 'other', name: 'Other' }
],
placeholder: 'Select your role'
}, '1fr');
});
page5.addRow(row => {
row.addCheckboxList('consent', {
options: [
{ id: 'report', name: '📄 Send me the detailed PDF cost analysis', isRequired: true },
{ id: 'tips', name: '💡 Send me data quality best practices' },
{ id: 'demo', name: '📞 I want a demo of data quality solutions' }
],
defaultValue: ['report'],
orientation: 'vertical'
});
});
// ============ PDF REPORT ============
form.configurePdf('data-cost-report', pdf => {
pdf.configure({
filename: 'bad-data-cost-analysis.pdf',
pageSize: 'A4',
allowUserDownload: true,
downloadButtonLabel: '📄 Download Cost Analysis',
header: { title: 'Bad Data Cost Analysis Report', subtitle: 'Data Quality ROI Assessment' },
footer: { text: 'Generated by FormTs Data Quality Calculator', showPageNumbers: true }
});
pdf.addSection('Executive Summary', section => {
section.addRow(row => {
row.addField('Total Annual Cost', formatCurrency(getTotalAnnualCost()));
row.addField('Potential Savings', formatCurrency(getPotentialSavings()));
});
section.addRow(row => {
row.addField('Employees Using Data', `${getEmployeesUsingData()}`);
row.addField('Assessment Date', new Date().toLocaleDateString());
});
});
pdf.addSection('Cost Breakdown', section => {
section.addTable(
['Cost Category', 'Annual Cost', '% of Total'],
[
['Time Wasted on Bad Data', formatCurrency(getTotalTimeCost()), `${Math.round(getTotalTimeCost() / getTotalAnnualCost() * 100)}%`],
['Duplicate Records', formatCurrency(getDuplicateCost()), `${Math.round(getDuplicateCost() / getTotalAnnualCost() * 100)}%`],
['Poor Decision Cost', formatCurrency(getDecisionCost()), `${Math.round(getDecisionCost() / getTotalAnnualCost() * 100)}%`],
['Customer Impact', formatCurrency(getCustomerImpactCost()), `${Math.round(getCustomerImpactCost() / getTotalAnnualCost() * 100)}%`],
['TOTAL', formatCurrency(getTotalAnnualCost()), '100%']
]
);
});
pdf.addSection('Input Assumptions', section => {
const i = inputs();
section.addRow(row => {
row.addField('Employees', `${i.employees}`);
row.addField('Avg Salary', formatCurrency(i.avgSalary));
});
section.addRow(row => {
row.addField('Data Hours/Week', `${i.dataHoursWeek}`);
row.addField('Error Rate', `${i.errorRate}%`);
});
section.addRow(row => {
row.addField('Duplicate Rate', `${i.duplicateRate}%`);
row.addField('Decay Rate', `${i.decayRate}%/year`);
});
});
pdf.addPageBreak();
pdf.addSection('Recommended Actions', section => {
section.addText('1. Implement data validation rules at point of entry');
section.addText('2. Run regular duplicate detection and merge processes');
section.addText('3. Establish data decay monitoring and refresh procedures');
section.addText('4. Create data quality KPIs and dashboards');
section.addText('5. Train staff on data entry best practices');
section.addText('6. Consider automated data quality tools for continuous monitoring');
});
});
// ============ SUBMIT BUTTON ============
form.configureSubmitButton({
label: () => `📊 Get My Cost Analysis (${formatCurrency(getTotalAnnualCost())})`
});
form.configureSubmitBehavior({ sendToServer: true });
}