I would like to create a measure that displays “Salesperson Goal Current Year”.
I am having trouble setting up my data model. I cannot connect ‘Dim Salesperson_Goals’ to both ‘Dim Salesperson’ and ‘Fact Sales_Invoices_By_Rep’ without creating a circular relationship.
I want to be able to store many years’ goals for each sales rep in the ‘Dim Salesperson_Goals’ table, but am at a loss for how to set up the data model and DAX formula.
I have the following tables;
-
Dim Salesperson
- Field 1: Salesperson Code
- Field 2: Salesperson Name
-
Dim Dates
- Field 1: Date
-
Fact Sales_Invoices_By_Rep
- Field 1: Sales Invoice No.
- Field 2: Invoice Date [related to Dim Dates]
- Field 3: Salesperson Code [related to Dim Salesperson]
- Field 4: Invoice Total
-
Dim Salesperson_Goals
- Field 1: Salesperson Code [related to Dim Salesperson]
- Field 2: Goal
- Field 3: Some Date Field, perhaps last date of the applicable year [needs a relation]
For some additional context, here’s a snapshot of my current visualization. Everything works as I’d like it to except: no matter which year is sliced, the goal amount is always the same. This is because my current Salesperson Goal measure is simply SUM('Dim Salesperson_Goals'[Goal])
and has no linkage to the dates table.
Image below shows visualization:
https://imgur.com/a/Ajj215K
Image below shows field list:
https://imgur.com/a/kQVUhmh
Image below shows data model:
https://imgur.com/a/YbtRphI
Here are my measures:
The goal itself, which is the DAX/Data Modelling I am having trouble filtering appropriately:
Salesperson Goal = SUM('Dim Salesperson_Goals'[Quota])
Attainment to goal (green):
Salesperson Attainment to Goal = IF([Salesperson Goal] - [Invoiced GP by Rep YTD] >= 0, [Invoiced GP by Rep YTD], [Salesperson Goal])
Salesperson Open Booked to Goal = IF([Invoiced GP by Rep YTD] + [Open Booked GP by Rep YTD] <= [Salesperson Goal], [Open Booked GP by Rep YTD], IF([Salesperson Goal] - [Invoiced GP by Rep YTD] >= 0, [Salesperson Goal] - [Invoiced GP by Rep YTD], 0))
Attainment beyond goal (gold):
Salesperson Open Booked Beyond Goal = IF([Invoiced GP by Rep YTD] + [Open Booked GP by Rep YTD] <= [Salesperson Goal], 0, [Open Booked GP by Rep YTD] - [Salesperson Open Booked to Goal])
Salesperson Attainment Beyond Goal = IF([Salesperson Attainment to Goal] < [Salesperson Goal], 0, [Invoiced GP by Rep YTD] - [Salesperson Goal])
How might I go about storing these goal values in a way that allows date filtering without creating a circular relationship?
Note: Currently, my 'Dim Salesperson_Goals'
table only stores 2019 goals, otherwise the graphic would be much further removed from reality. I’m trying to get the 2019 goals to disappear when filtering by 2020.