简体   繁体   English

如何在 Power BI 中可视化具有独特每月目标的循环多年 KPI?

[英]How can I visualize a revolving multi-year KPI with unique monthly targets in Power BI?

I need help developing an approach for a line chart that visualizes actual sales against a monthly KPI sales goal over 24 months.我需要帮助开发一种折线图方法,该方法可以根据 24 个月的每月 KPI 销售目标可视化实际销售额。

We have an annual sales goal, tracked until completion for two years at a time.我们有一个年度销售目标,一次跟踪直到完成两年。 Every month for the 1st year of the goal, we are supposed to achieve 4.0% of the goal.目标第一年的每个月,我们应该实现目标的 4.0%。 In the second year, the monthly goal shifts to 4.3%.在第二年,每月目标变为 4.3%。

2021 goal: $1,000,000 in sales, due on 1/1/2023 2021 年目标:销售额 1,000,000 美元,将于 2023 年 1 月 1 日到期

2022 goal: $2,000,000 in sales, due on 1/1/2024 2022 年目标:销售额 2,000,000 美元,将于 2024 年 1 月 1 日到期

The dashboard visual needs to understand that it is looking at a goal that began in any X year, and then visualize the calculated monthly targets for 24 months until the goal's due date 2 years later.仪表板视觉对象需要了解它正在查看从任何 X 年开始的目标,然后可视化计算的 24 个月的每月目标,直到目标在 2 年后的到期日。 The goal amount cannot be hardcoded, it varies by team and can be shifted throughout the 2 year period based on certain factors so it's already a calculated measure [Annual Goal].目标金额不能硬编码,它因团队而异,并且可以根据某些因素在整个 2 年期间进行调整,因此它已经是一个计算的衡量标准 [年度目标]。

I've gone in circles thinking DAX, Power Query, Data model relationships, but I hit a wall every time.我一直在思考 DAX、Power Query、数据 model 关系,但我每次都碰壁。 It seems like I need to group the data in 24 month increments but I don't know how.似乎我需要以 24 个月的增量对数据进行分组,但我不知道如何。 I've also looked at merging the goals in the Query editor with the raw data, but that duplicates the goal values and makes them difficult to plot.我还研究了将查询编辑器中的目标与原始数据合并,但这会重复目标值并使它们难以 plot。 I can't figure out a data model relationship because there isn't a clear connection between the raw sales numbers that are tied to actual dates and the goals table tied to any given base year.我无法弄清楚数据 model 关系,因为与实际日期相关的原始销售数字与与任何给定基准年相关的目标表之间没有明确的联系。

Goal table目标表

Goal % | Goal Raw           |  Month    |   Year
4.0%   | Sales Goal*.04     |  January  |  Year 1
4.0%   | Sales Goal *.04    |  February |  Year 1
etc       etc
4.3%   | Sales Goal*.043    |  January  |  Year 2
4.3%   | Sales Goal *.043   |  February |  Year 2

Sales Table销售表

    Sale     | Date             |  Month    |   
    $10000   | 10/15/2021       |  October  |  
    $11000   | 10/15/2021       |  October  |  
    $9500    | 10/15/2021       |  October  | 

My end visualization would be based off of a table like this:我的最终可视化将基于这样的表格:

Sale    |   Sale % of Goal  |  Month Target Goal %    | Month   | Year 
 $1000  |   1%              |   4.0%                  | October | 2020
 $1000  |   1%              |   4.0%                  | October | 2020
 $1000  |   1%              |   4.3%                  | February| 2021
 $1000  |   1%              |   4.3%                  | February| 2021

So you have a measure that gives you the [Annual Goal] for whatever year you select.所以你有一个衡量标准,可以为你提供 select 的任何一年的[Annual Goal] I presume that that measure can be filtered by some slicer Year which will return the goal for the correct year (starting point).我认为该度量可以通过某些切片器Year过滤,这将返回正确年份的目标(起点)。

Let's also assume that you have some sort of table with the calendar which you can use as the X-Axis of your line chart.我们还假设您有某种带有日历的表格,您可以将其用作折线图的 X 轴。

You can then create 2 measures to be used on the line chart:然后,您可以创建 2 个要在折线图上使用的度量:

//Measure 1
Annual Goal Cumulative = 
  VAR _year = SELECTEDVALUE(YearSlicer[Year])
  VAR _x_month = SELECTEDVALUE(Date[date])
  VAR _no_months = DATEDIFF(DATE(_year,1,1), _x_month, MONTH)

  VAR _pct_target = IF(_no_months <= 12, 
         _no_months * 0.04, 
         0.48 + (_no_months - 12) * 0.043)
  
  RETURN IF( _no_months >=0 && _no_months <= 24, 
     [Annual Goal] * _pct_target, 
     BLANK()
  )

//Measure 2
Sales Cumulative =
  VAR _year = SELECTEDVALUE(YearSlicer[Year])
  VAR _start_date = DATE(_year,1,1)

  VAR _x_month = SELECTEDVALUE(Date[date])
  VAR _no_months = DATEDIFF(_start_date, _x_month, MONTH)

  RETURN IF( _no_months >=0 && _no_months <= 24, 
     CALCULATE(SUM(sales[Sale]), 
        sales[Date] >= _start_date && 
        sales[Date] < EOMONTH(_x_month, 1) + 1 //watch out for the last day of month edge cases
     ),
     BLANK()
     )

Plot these 2 measures on a line chart and you should see the progress of sales against the annual target spread over 24 months. Plot 折线图上的这 2 个度量值,您应该可以看到销售进度相对于年度目标分布在 24 个月内。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM