Forum Discussion

kcantor's avatar
kcantor
Icon for Community Champion rankCommunity Champion
10 years ago

Use PowerQuery/M to calculate time in pod

I have ordered the book on M but still haven’t learned enough to be of any use. So, here I am again on the board asking for help making powerquery do my bidding.

I have a ‘Pod Members” table that I need to create a couple of calculations on. It has true duplicate entries that I need to remove in order to make the pivot table work but I don't  know how to automatically judge which entry to keep. I also need to calculate days in pod, days in training, and, using that calculation create pod memberships.

I have attached a modified version of the table here. The names have been changed to protect the innocent.

Steps I need to create:

1.)  Determine current pod membership. If a team member is currently in the pod, the end date will be 12/31/9999.  Remove/hide duplicate member names that have left a pod. In the attached table there should be 3 examples of those duplicates. Of course the next step may need part of the information from the deleted entries.

2.)  Determine if the member is in training. A member is in training if their start date is less than 45 days from the current date. After 45 days, they are no longer in training and count in calculations as a pod member. MSTARTED is not a new hire/ trainee but has switched to a new pod in the example.

3.)  Create a method of calculating pod current pod membership to be used as a divisor in sales calculations. I need to be able to divide sales calls and sales dollars by the number of current pod members who are out of training.  So, if a member is new, their calls and sales dollars count but the divisor is different. For example,  JLENON is in the Sales Ninjas pod but has not been with us for 45 days. Therefore, the Sales Ninjas pod membership count should be 2, not 3 until his training is complete.

4.)  As a wish list item, I would like to add a new column calculating the number of days spent in the new pod in case someone switched pods in the middle of a calculation period. My fear on this is how to keep them in two pods without creating duplicate entries that would negate table relationships. As a way to split sales calls and sales dollars between two pods if they changed to another.

As always, I appreciate your help and the sharing of your wisdom.

 

SalesPersonCodeFirst Training DateTopPodCodeStart DateEnd DateTopPodNameid
ALINCOLN9/23/2014 0:00TT1/1/2015 0:0012/31/9999 0:00Team Troll99
BCAUGHT10/27/2015 0:00BP2/6/2016 0:0012/31/9999 0:00Bro Pod57
BCAUGHT10/27/2015 0:00SJ10/27/2015 0:002/5/2016 0:00Sales Jedis58
FPAPER11/10/2015 0:00SJ11/10/2015 0:002/22/2016 0:00Sales Jedis108
GWASHINGTON1/5/2016 0:00BP1/5/2016 0:0012/31/9999 0:00Bro Pod109
JBEIBER2/17/2016 0:00SJ2/17/2016 0:0012/31/9999 0:00Sales Jedis261
JCASTILLION4/15/2014 0:00BP1/1/2015 0:001/12/2016 0:00Bro Pod317
JCASTILLION4/15/2014 0:00DP1/13/2016 0:0012/31/9999 0:00Digital Pod318
JLENON2/25/2016 0:00SN2/25/2016 0:0012/31/9999 0:00Sales Ninjas86
JOCEAN6/30/2015 0:00TT6/30/2015 0:0012/31/9999 0:00Team Troll141
KPEAN1/6/2011 0:00SN1/1/2015 0:0012/31/9999 0:00Sales Ninjas56
MSTARTED8/13/2013 0:00BC1/1/2015 0:004/1/2016 0:00Big Cheese205
MSTARTED8/13/2013 0:00DP4/2/2016 0:0012/31/9999 0:00Digital Pod206
NFASHION5/6/2013 0:00TT1/1/2015 0:0012/31/9999 0:00Team Troll222
OOSBORNE9/8/2015 0:00BC9/8/2015 0:0012/31/9999 0:00Big Cheese245
PFRAMPTON9/28/2010 0:00BC1/1/2015 0:0012/31/9999 0:00Big Cheese61
PMCCARTNEY8/11/2015 0:00SN8/11/2015 0:0012/31/9999 0:00Sales Ninjas81
STYLER3/18/2014 0:00BP1/1/2015 0:0012/31/9999 0:00Bro Pod78
TWEET5/27/2014 0:00BC1/1/2015 0:009/7/2015 0:00Big Cheese305
TWEET5/27/2014 0:00SJ9/8/2015 0:0012/31/9999 0:00Sales Jedis306

7 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi kcantor,

     

       such a lot of things to do. I'll check out if I can give you an hand.

    Thanks for the example table, perfect for a copy&paste in Excel.

     

    #I'M Not An Expert#

    • kcantor's avatar
      kcantor
      Icon for Community Champion rankCommunity Champion

      MattAllington

      Can you post the link for your book here? I have requested a copy from the PTB but would prefer to order from your link so I get instant access.  I am  STUMPED on PowerQuery.

    • kcantor's avatar
      kcantor
      Icon for Community Champion rankCommunity Champion

      Your assistance would be greatly appreciated Anonymous. I have reached the point of frustration and have actually built a couple of columns in a drastic attempt to overcome my lack of PowerQuery skills.