Forum Discussion

Craterdee's avatar
Craterdee
Regular Visitor
1 year ago
Solved

Help with data prep

Hi gang,

 

I am attempting to "clean" my data so that I can get stats by truck, by proportionate share.

 

1. How can I get a list of orders by truck no. (so if an order has 3 trucks assigned to it, I would lie 3 lines instead of 1) If I split data, then I end up with as many columns as I have trucks for any given order

2. How can I assign a % of revenue to each order per truck (see below - CITY alone = 100% / HWY alone = 100% / 1 HWY = 70% with 1 CITY = 30% // So if two HWY trucks + 1 City truck, % should be 35-35-30)

 

I am stuck.

 

Thank you all for your help 🙂 Chrisitne

 

Here is my data table:

 

WO #CurrencyDelivery dateAmountTruck
048976CAD2024-08-05675MEI Truck 102; MEI Truck 22
049001CAD2024-08-02400

MEI Truck 103

049099CAD2024-08-151800MEI Truck 103
049123CAD2024-08-16250MEI Truck 103
049031CAD2024-08-071650MEI Truck 103; MEI Truck 22
049089CAD2024-08-19600MEI Truck 103; MEI Truck 23
049103CAD2024-08-191300MEI Truck 103; MEI Truck 23
049115CAD2024-08-191850MEI Truck 103; MEI Truck 23
049144CAD2024-08-19440MEI Truck 103; MEI Truck 23
049164CAD2024-08-22900MEI Truck 103; MEI Truck 23
049196CAD2024-08-23500MEI Truck 103; MEI Truck 23
049203CAD2024-08-261350MEI Truck 103; MEI Truck 23
049265CAD2024-08-302000MEI Truck 103; MEI Truck 23
049238CAD2024-08-283050MEI Truck 103; MEI Truck 23; MEI Truck 38

 

Master data:

IDType
22HWY
23HWY
25HWY
30HWY
34HWY
35HWY
37HWY
38HWY
39HWY
40HWY
41HWY
42HWY
43HWY
104City
105City

 

Combo12345 
City100%    100%
City - City50%50%   100%
City - City - HWY15%15%70%  100%
City - City - HWY - Sub15%15%35%35% 100%
City - City - HWY - HWY15%15%35%35% 100%
City - City - HWY - HWY - HWY15%15%23%23%23%100%
City - HWY30%70%   100%
City - HWY - HWY30%35%35%  100%
City - HWY - HWY - HWY30%23%23%23% 100%
City - HWY - HWY - HWY - HWY30%18%18%18%18%100%
City - HWY - HWY - Sub30%23%23%23% 100%
HWY100%    100%
HWY - HWY50%50%   100%
HWY - HWY - HWY33%33%33%  100%
Agent100%    100%
City - Sub30%70%   100%
HWY - Sub50%50%   100%
Sub100%    100%
HWY - HWY - Sub33%33%33%  100%
City - HWY - Sub30%35%35%  100%
City - City - Sub15%15%70%  100%

 

 

  • You are indeed a super user!!!  Thank you very much.

     

    Now, I will actually go study the formulas 🙂

     

    Very appreciated. 

     

    Chrsitine

7 Replies

  • Hi Craterdee ,

     

    I don't understand the question about the hierarchy but concerning the number of rows you should do the following in Power Query:

    • Select the Truck colum
    • Go to transform 
    • Select Split columns
    • Split by delimiter ", "
    • Select advance and split to rows

       

      This will give you the following result:

     

    Now you can have the number of rows by WO.

     

    Can you share some more information about the hierarchy please.

    • Craterdee's avatar
      Craterdee
      Regular Visitor

      Thank you for that information!

       

      Next, I need to determine the % of sales for each truck  in any given order.

       

      In this case, Order # 49238 has 3 trucks assigned to it - 103 is CITY / 23 is HWY / 38 is HWY therefore I need 30% of the sale to be assigned to truck 103, 35% (1/2 of 70%) to be assigned to 23 and 35% to be assigned to 38

       

      049238CAD2024-08-283050MEI Truck 103; MEI Truck 23; MEI Truck 38

       

      In this case, Order # 49031 has 2 trucks assigned to it - 103 is CITY / 22 is HWY therefore I need 30% of the sale to be assigned to 103, and 70% to be assigned to 22

       

       

      049031CAD2024-08-071650MEI Truck 103; MEI Truck 22

       

      If I have 2 city trucks and 3 HWY trucks assigned to an order, I would need calculate 15% of sales for each city truck and (70%/3) of sales for each HWY truck

       

      City trucks must total 30% of the order's sale amount / HWY trucks 70% 

       

      Does this better describe my issue?

       

      Thanks, Christine

      • MFelix's avatar
        MFelix
        Super User

        Try the following two measures:

         

        Calculation = 
         var _CITY = 0.30
        var _HWY = 0.70
        var _TruckCount = CALCULATE(COUNTROWS(WO), WO[WO #] = SELECTEDVALUE(WO[WO #]), REMOVEFILTERS(MasterData[ID]))
        var _Result =  IF(SELECTEDVALUE(MasterData[Type])  = "City", DIVIDE(_CITY, _TruckCount), DIVIDE(_HWY, _TruckCount)
        )
        RETURN
        _Result
        
        
        Final Value = 
        
         SUMX(WO, [Calculation])
        

         

        I have one question that is about when there is only one type of truck how do you split is it based on the 100%