首页 > 解决方案 > Tableau GAP & 预测公式 & 按月+季度显示

问题描述

我有 excel 数据源(如下所示),我想将 4 个计算字段 (CF) 显示为(红色突出显示),以黄色突出显示 4 个“团队”。所需输出以绿色突出显示。

在此处输入图像描述

我得到的输出如图所示:

在此处输入图像描述

面临的问题:

  1. 无法找到预测和 GAP 的正确答案。使用的公式如下:
  2. 如何仅按月表示(销售数量),但在 QUARTER 级别显示所有 4 个 CF,如上图绿色所示。

    # of sales = COUNT([Productname])
    
    Days Passed = DAY([Sale Date])-day(TODAY())
    
    Forecast = (([#ofSales]))/(avg([DaysPassed]))*avg([TotalDays])
    
    SalesTarget (copy) = { FIXED [Team], quarter([Sale Date])=1 : avg([SalesTarget])}
    
    GAP = (sum([SalesTarget (copy)]))-[Forecast]
    
    TotalDays = if quarter([Sale Date])=1 then 91 
        ELSEIF quarter([Sale Date])=2 then 92
        ELSEIF quarter([Sale Date])=3 then 92
        ELSEIF quarter([Sale Date])=4 then 92 end
    
    SalesTarget = if [Team]="USA Small" and quarter([Sale Date])=1 then 10
        ELSEIF [Team]="USA Big" and quarter([Sale Date])=1 then 5
        ELSEIF [Team]="UK Small" and quarter([Sale Date])=1 then 3
        ELSEIF [Team]="UK Big" and quarter([Sale Date])=1 then 3
        END
    
    SalesTarget (copy) = { FIXED [Team], quarter([Sale Date])=1 : avg([SalesTarget])}
    

我尝试了多种解决方法,但找不到解决方案。我无法在 Stack Overflow 中附加任何文件。所以只添加了几个代码示例,我尝试了很多。

标签: tableau-apicalculated-field

解决方案


推荐阅读