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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
User_790790
New Member

Obtaining target by branch, category, agent and month.

I need to show sales against target in PowerBi by Agent ID , Branch & Category 1. Even if the customer has no sale in a particular category.

 

This is the sales data

 

DateCategoryCategory- 1Branch CodeAgent IDDesignationSales
01-02-24PostPost-VOICEPRLAB017Sales Rep27
01-02-24PostPost-DATAPRLAB017Sales Rep

2

0

01-02-24PostPost-DATAPACAB013Sales Manager21
01-02-24PostPost-VOICEOACAB027Sales Rep22
02-02-24PostPost-DATAOACAB027Sales Rep24
02-02-24PostPost-VOICEOACAB027Sales Rep10
01-02-24PrePre-DATAOACAB027Sales Rep11
01-02-24PrePre-VOICEPRLAB017Sales Rep13
01-02-24ZZPACAB013Sales Manager21
01-02-24ZZOACAB027Sales Rep24
02-02-24PostPost-VOICEPRLAB017Sales Rep21
02-02-24PostPost-DATAPRLAB017Sales Rep18
02-02-24PostPost-DATAPACAB013Sales Manager22
02-02-24PostPost-VOICEOACAB027Sales Rep21
02-02-24PostPost-VOICEOACAB027Sales Rep15
02-02-24PostPost-VOICEOACAB027Sales Rep18
02-02-24PrePre-VOICEOACAB027Sales Rep16
02-02-24PrePre-VOICEPRLAB017Sales Rep13
02-02-24ZZPACAB013Sales Manager11
02-02-24ZZOACAB027Sales Rep21
02-02-24ZZPRLAB017Sales Rep21
02-02-24PrePre-DATAPRLAB017Sales Rep10
02-02-24PrePre-DataPACAB013Sales Manager26
02-02-24PostPost-VoicePACAB013Sales Manager12

 

This is the target data

Month-YearBranch CategoryCategory - 1DesignationTarget
Feb-23PRLPostPost-VOICESales Rep60
Feb-23PRLPostPost-DATASales Rep60
Feb-23PRLPrePre-DATASales Rep64
Feb-23PRLPrePre-VOICESales Rep51
Feb-23PRLZZSales Rep60
Feb-23OACPostPost-VOICESales Rep150
Feb-23OACPostPost-DATASales Rep64
Feb-23OACPrePre-DATASales Rep55
Feb-23OACPrePre-VOICESales Rep60
Feb-23OACZZSales Rep69
Feb-23PACPostPost-VOICESales Manager30
Feb-23PACPostPost-DATASales Manager61
Feb-23PACPrePre-DATASales Manager52
Feb-23PACPrePre-VOICESales Manager62
Feb-23PACZZSales Manager63

 

Desired Output : - I require it in this format so I that I can create a visualtion and few calculations.

 

Agent ID BranchCategory-1SalesTarget
AB027OACPost-DATA2464
AB027OACPost-VOICE86150
AB027OACPre-DATA1155
AB027OACPre-VOICE1660
AB027OACZ4569
AB017PRLPost-DATA3860
AB017PRLPost-VOICE4860
AB017PRLPre-DATA1064
AB017PRLPre-VOICE2651
AB017PRLZ2160
AB013PACPost-DATA4361
AB013PACPost-VOICE1230
AB013PACPre-DATA2652
AB013PACPre-VOICE62
AB013PACZ3263
4 REPLIES 4
v-kongfanf-msft
Community Support
Community Support

Hi @User_790790 ,

 

Based on the information you have provided, it is not possible to establish a relationship between the sales and target tables by specific fields.

vkongfanfmsft_0-1714544896736.png

 

Best Regards,
Adamk Kong

audreygerred
Super User
Super User

Hello! You should structure the data so that it follows star schema (fact and dimension), here is a blog post I wrote that explains it in more detail: http://powerbiwithme.com/2023/07/30/the-star-schema-edition/

 

For your model, you will want to have a category dimension table that has Category 1 and Category. Ideally you would have surrogate keys and such for best practice, but for now, you can just use Category 1 as your key - you would join Category 1 from your new dimension table (this dim table will have Category 1 listed one time only and the corresponding category, this way Category 1 is unique in the dim table) to each of your tables. 

 

You would also need a date dim table: http://powerbiwithme.com/2023/08/01/the-custom-date-table-edition/

 

One potential issue I see as the data is now is that you want to show targets by AgentID, but AgentID is not part of the target table. 

 

You will also need a Branch table that then joins to each of your tables. And, and Agent dimension table (with AgentID also added into the target table if you plan to use AgentID to show targets).

 

Once you have this and you make your visual, you would grab Agent ID from the Agent dim table, Branch from the Branch dim table, and Category from the Category dim table.

 

Then, you would pull in your measures for Sales and Target: Sales = SUM('SalesTable'[Sales]) and Target = SUM('TargetTable'[Target])

 

As of right now, target would not work if you had AgentID in a visual since Target table is not at that level of granularity.




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Hey @audreygerred , 

Thanks for your response. Regarding the agent target, I receive the target data like this:

 

eg. for branch - oac , category 1 - z , designation - sales rep, target - 69.

 

so all the sales rep in the branch for that particular category will have that target.

 

If add an Agent ID column , it would be a very large dataset. Since I would have to add agent id by 5 categories and targets . In my original dataset I have about 80+ agents and I have to consider each month as well.

 

For eg. 

MonthAgent ID BranchCategoryCategory-1Target
Feb-24AB027OACPostPost-DATA64
Feb-24AB027OACPostPost-VOICE150
Feb-24AB027OACPrePre-DATA55
Feb-24AB027OACPrePre-VOICE60
Feb-24AB027OACZZ69
Mar-24AB027OACPostPost-DATA62
Mar-24AB027OACPostPost-VOICE130
Mar-24AB027OACPrePre-DATA51
Mar-24AB027OACPrePre-VOICE67
Mar-24AB027OACZZ63

 

Should I take this approach or is there an alternative i could consider?

Yes, if you want to report your target by Agent ID, you will need the target by Agent ID. Although it may seem like a lot of data, it really isn't. Power BI is great with compression. 




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.