简体   繁体   中英

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.

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. In the second year, the monthly goal shifts to 4.3%.

2021 goal: $1,000,000 in sales, due on 1/1/2023

2022 goal: $2,000,000 in sales, due on 1/1/2024

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. 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].

I've gone in circles thinking DAX, Power Query, Data model relationships, but I hit a wall every time. It seems like I need to group the data in 24 month increments but I don't know how. 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. 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.

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. I presume that that measure can be filtered by some slicer Year which will return the goal for the correct year (starting point).

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.

You can then create 2 measures to be used on the line chart:

//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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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