Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Calculating performance vs. target; 'left to get' versus target; performance growth in % terms

I am a new power BI user and just coming to grips with the setup. I have a large flat file loaded from excel with performance by sales rep across multiple years, multiple quarters. at a deal / transaction level.

 

I have loaded in a separate table with the targets by sales rep, by quarter.

 

I'd now like to create 3 calculations:

- Sales rep performance (sum of USD performance) versus target expressed as a percentage, for the selected QTR

- Sales rep 'left to get' versus target (i.e. target minus sum of performance) for selected QTR, but left to get cannot be less than zero i.e. if performance is greater than the target, then left to get should be zero

- Sales rep performance growth / decline in % terms versus another selected QTR

 

I think this is going to involve DAX but I'm not sure where to start.

 

Very grateful for some help.

 

Tables below are Data. Then Targets. The picture is the relationships.

Capture.JPG

 

Opportunity NameService OfferingUSD ValueRegionStageForecastFY&QSales Rep
Randomtext - 3724384903Offering 54723.23SouthWonClosedFY13 Q2John Doe 1
Randomtext - 2761410753Offering 30UKProspectedPipelineFY19 Q1John Doe 2
Randomtext - 2271928993Offering 548613NordicsQualified OutClosedFY12 Q2John Doe 3
Randomtext - 1942677260Offering 254.11NordicsWonClosedFY18 Q4John Doe 4
Randomtext - 5101192472Offering 534642.03NordicsQualified OutClosedFY13 Q4John Doe 5
Randomtext - 7975257163Offering 60SouthQualified OutClosedFY19 Q1John Doe 6
Randomtext - 5482864152Offering 5371.67SouthWonClosedFY12 Q4John Doe 6
Randomtext - 3828510690Offering 1537.12NordicsInLegalCommitFY19 Q1John Doe 7
Randomtext - 1195647477Offering 532992.41NordicsQualified OutClosedFY13 Q4John Doe 8
Randomtext - 8467719711Offering 30WestQualified OutClosedFY18 Q4John Doe 9
Randomtext - 7577179194Offering 53150MidwestWonClosedFY13 Q4John Doe 10

 

Sales RepFY18 Q1FY18 Q2FY18 Q3FY18 Q4FY19 Q1
John Doe 12100056000950009100042000
John Doe 21400095000220008600015000
John Doe 36300078000670009300074000
John Doe 44800032000620004400050000
John Doe 58700055000650001500068000
John Doe 6260008500072000100008000
John Doe 78800099000790005800045000
John Doe 83800015000390005200076000
John Doe 99100084000140007600071000
John Doe 105000061000290009400078000
8 REPLIES 8
v-frfei-msft
Community Support
Community Support

Hi @Anonymous ,

 

One sample for your reference. Please check the following steps as below.

 

1. Unpivot the Targets table, please refer to the M code in power query as below.

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("ZZG9DoMwDIRfBTEzxEn8k71TXwExVupU3n9rrFxUqKcThz/77Oz7+jzfn+VxvhZatzVTSqkry9DGUPg1ux7bBcvdpnovz3mooQ1xwEq3pYzfakNF0Wb6NWDVQ6C8YIpAK1L4sD+MPQy6M0IKX8P1bwuY+C7YwVCmmEYJfqDUXWRsDRSU4dd4EfOV7J6pTAxDVQLWLs9juMB8D0V2pYDR71J9dfAZ49rkx3LHFw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [#"Sales Rep" = _t, #"FY18 Q1" = _t, #"FY18 Q2" = _t, #"FY18 Q3" = _t, #"FY18 Q4" = _t, #"FY19 Q1" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Sales Rep", type text}, {"FY18 Q1", Int64.Type}, {"FY18 Q2", Int64.Type}, {"FY18 Q3", Int64.Type}, {"FY18 Q4", Int64.Type}, {"FY19 Q1", Int64.Type}}),
    #"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Sales Rep"}, "Attribute", "Value")
in
    #"Unpivoted Columns"

 

2. We need create three calculated tables as below.

 

Sales Rep = DISTINCT(UNION(VALUES(Data[Sales Rep]),VALUES('Targets'[Sales Rep])))
FY = DISTINCT(UNION(VALUES(Data[FY&Q]),VALUES(Targets[Attribute])))
another selected QTR = VALUES(FY[FY&Q])

3. Then create relationship between tables as the pic.

 

Capture.PNG

 

4.Afther that we can create three measures to get the results as we need.

 

Sales rep performance = 
CALCULATE ( SUM ( Data[USD Value] ) ) / CALCULATE ( SUM ( Targets[Value] ) )
left to get = 
VAR _data =
    CALCULATE ( SUM ( Data[USD Value] ) )
VAR _tar =
    CALCULATE ( SUM ( Targets[Value] ) )
VAR _min = _tar - _data
RETURN
    IF ( _min > 0, _min / _tar, 0 )
Sales rep performance growth = 
VAR _sele =
    CALCULATE (
        SUM ( Data[USD Value] ),
        FILTER ( ALL ( Data ), 'Data'[FY&Q] = SELECTEDVALUE ( FY[FY&Q] ) ),
        VALUES ( Data[Sales Rep] )
    )
VAR sele2 =
    CALCULATE (
        SUM ( Targets[Value] ),
        FILTER ( ALL ( Targets ), 'Targets'[Attribute] = SELECTEDVALUE ( FY[FY&Q] ) ),
        VALUES ( Targets[Sales Rep] )
    )
RETURN
    DIVIDE ( [Sales rep performance] - _sele / sele2, _sele / sele2 )

result.PNG

 

For more details, please check the pbix as attached.

 

Regards,

Frank

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.
Anonymous
Not applicable

@v-frfei-msftHi. I am working with the dummy file / your pbix, and moving info back in to my working model as I work through the components and understand them.

 

When I bring in the 'Left to Get' calculated measure (which you helped me to create) to a table on my visualizations panel, it has the strange effect of calculating left to get for roles / reps that have been filtered out using page level filters. This forces the table to dramatically expand and include people / roles that were filtered out prior to adding in the calculated measure.

 

I can see that the page level filters have been applied to the visual level filters, but the unwanted info still shows in the table.

 

Is there any way to prevent this from happening?

Hi @Anonymous ,

 

Did you create correct relationships between tables? And did you add the same columns as my pbix to the visual?

 

Regards,

Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.
Anonymous
Not applicable

Thanks @v-frfei-msft - I am still working this through and following the logic.

 

Why did you need to create the 2 calculated tables of FY and Sales Rep? These fields already exist in 'data'. Why can't we just create a relationship between the data table and the targets table?

Hi @Anonymous ,

 

If we create a relationship between the data table and the targets table and create slicers for the columns you want to filter. The table will be filtered and you will not get the correct result in the measure as we create.

 

Regards,

Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

Hi,

 

After unpivoting the target table, there will be duplicates appearing in the Sales rep column.  For a relationship to flow from the Sales rep column of the Data Table to the Sales rep column of the Target table, the Sales rep column of the Target table should only have unique values.  So that is the primary reason.  Furthermore, whenever, there is a Date column, there should always be  Calendar Table so that you can use Date/Time Intelligence functions.  Both the target table and the Data Table should be linked to the Calendar Table.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

Thanks @Ashish_Mathur -

 

So any time I want to use a field in power BI that has duplicate values in the underlying data, I would need to create the calculated table? That seems incredibly onerous. I am new to PowerBi but up until the time that I posted this question, I (appear to!) have managed fine without having to do this.

 

Would appreciate some further detail on when it is appropriate / required to do this, and when it is not.

Hi,

 

In the Table on the 1 side of a Many to one relationship, the column that you are drawing a relationship to should have unique values.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors