google-sheets - 谷歌表格中的销售计划仪表板
问题描述
测试表:
https://docs.google.com/spreadsheets/d/1t_hjD6Yx7iv_a9tcgETf82cZbl2cdV8vd0PuTQXZP6Y/edit?usp=sharing
客观的:
我正在尝试为我的一位客户创建一个自动计划表。工作表的想法是:
- 在单元格中手动输入总销售目标
B1
- 按广告平台细分的退货成本、潜在客户和销售额
当前图纸设置:
单元格B1
是工作表中唯一的手动输入。对于 之间的表A4:G10
,以绿色突出显示的列是固定值。成本列B4:B10
和销售额列G4:G10
是计算字段。目标是计算潜在客户列的值,以使单元格中的销售额列的总和G10
等于单元格中的销售目标B1
。
计算每个渠道的潜在客户的约束:
每个广告平台都有它可以产生的最大潜在客户数量,如列中所示E4:E10
。因此,在此测试表中,Facebook 可以生成的最大潜在客户数为 500,必应为 1000,依此类推。
广告平台按列中显示的每条线索成本递增的顺序列出C4:C10
。所以上面的渠道是最便宜的,而下面的渠道是最贵的。目标是首先从最便宜的渠道最大化潜在客户,然后转移到下一个渠道,直到实现销售目标。在测试表中,我们需要先从 Facebook 获得 500 个潜在客户,然后从 Google Ads 获得 500 个潜在客户,然后从 Bing 获得 1000 个潜在客户,以此类推,直到 cell 中的总销售额G10
等于 cell 中的销售目标B1
。
我对此有点迷茫,如果您能与我分享任何帮助,我将不胜感激!
解决方案
我想出了如何做我需要的事情。我添加了一个按钮来触发脚本函数calculate()
进行计算。它是一个非常基本的脚本,我将发布另一个问题来确定它是否可以优化 - 我的实际工作表具有动态数量的广告平台,我仍然需要脚本来适应它。
脚本:
function calculate() {
// Get the planning sheet
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet()
var sheet = spreadsheet.getSheetByName('Planner')
// Get contract target as the input
var target = sheet.getRange('B1').getValue()
// Clear the pin cards list
sheet.getRange('D11:D15').clearContent()
// Set the value of the first channel
firstChannelValue(sheet, target)
// Set the value of the second channel
secondChannelValue(sheet, target)
// Set the value of the third channel
thirdChannelValue(sheet, target)
// Set the value of the fourth channel
fourthChannelValue(sheet, target)
// Set the value of the fifth channel
fifthChannelValue(sheet, target)
}
function firstChannelValue(sheet, target) {
// Max number of pin cards
var pcLimit = sheet.getRange('E11').getValue()
// Conversion rate
var convRate = sheet.getRange('F11').getValue()
// Cell that needs to be filled
var pinCard = sheet.getRange('D11')
// Max possible value
var maxValue = pcLimit*convRate
// Set value of cell
if (maxValue <= target) {
pinCard.setValue(pcLimit)
}
else {
pinCard.setValue(target/convRate)
}
}
function secondChannelValue(sheet, target) {
// Max number of pin cards
var pcLimit = sheet.getRange('E12').getValue()
// Conversion rate
var convRate = sheet.getRange('F12').getValue()
// Cell that needs to be filled
var pinCard = sheet.getRange('D12')
// Max possible value
var maxValue = (pcLimit*convRate)
// Value of first channel contracts
var firstChannel = sheet.getRange('G11').getValue()
// Revised target
var revisedTarget = target - firstChannel
// Set value of cell
if (maxValue <= revisedTarget) {
pinCard.setValue(pcLimit)
}
else {
pinCard.setValue(revisedTarget/convRate)
}
}
function thirdChannelValue(sheet, target) {
// Max number of pin cards
var pcLimit = sheet.getRange('E13').getValue()
// Conversion rate
var convRate = sheet.getRange('F13').getValue()
// Cell that needs to be filled
var pinCard = sheet.getRange('D13')
// Max possible value
var maxValue = (pcLimit*convRate)
// Value of previous channel contracts
var firstChannel = sheet.getRange('G11').getValue()
var secondChannel = sheet.getRange('G12').getValue()
// Revised target
var revisedTarget = target - firstChannel - secondChannel
// Set value of cell
if (maxValue <= revisedTarget) {
pinCard.setValue(pcLimit)
}
else {
pinCard.setValue(revisedTarget/convRate)
}
}
function fourthChannelValue(sheet, target) {
// Max number of pin cards
var pcLimit = sheet.getRange('E14').getValue()
// Conversion rate
var convRate = sheet.getRange('F14').getValue()
// Cell that needs to be filled
var pinCard = sheet.getRange('D14')
// Max possible value
var maxValue = (pcLimit*convRate)
// Value of previous channel contracts
var firstChannel = sheet.getRange('G11').getValue()
var secondChannel = sheet.getRange('G12').getValue()
var thirdChannel = sheet.getRange('G13').getValue()
// Revised target
var revisedTarget = target - firstChannel - secondChannel - thirdChannel
// Set value of cell
if (maxValue <= revisedTarget) {
pinCard.setValue(pcLimit)
}
else {
pinCard.setValue(revisedTarget/convRate)
}
}
function fifthChannelValue(sheet, target) {
// Max number of pin cards
var pcLimit = sheet.getRange('E15').getValue()
// Conversion rate
var convRate = sheet.getRange('F15').getValue()
// Cell that needs to be filled
var pinCard = sheet.getRange('D15')
// Max possible value
var maxValue = (pcLimit*convRate)
// Value of previous channel contracts
var firstChannel = sheet.getRange('G11').getValue()
var secondChannel = sheet.getRange('G12').getValue()
var thirdChannel = sheet.getRange('G13').getValue()
var fourthChannel = sheet.getRange('G14').getValue()
// Revised target
var revisedTarget = target - firstChannel - secondChannel - thirdChannel - fourthChannel
// Set value of cell
if (maxValue <= revisedTarget) {
pinCard.setValue(pcLimit)
}
else {
pinCard.setValue(revisedTarget/convRate)
}
}
推荐阅读
- vb.net - 在非美国系统上从字符串转换日期
- javascript - scrollIntoView 后跟 console.log 时只工作一次
- sparql - 写一个查询,可以找到所有 NBA 篮球队的主教练
- linq - 使用 .Net 中的表达式使用动态查询时的 EF Core 性能问题
- keycloak - 所有按钮上的帐户控制台内部服务器错误
- c - 在 C 中的结构中传递值
- swift - 如何在 Swift 5 中仅使用 MapKit 显示城市
- php - 试图从我的用户表中选择 user_id = 1 但出现错误
- c# - TcpClient 连接正常,没有错误,但是没有收到数据包
- oracle - Oracle 嵌套 SUBSTR 比较