Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
ashokpaladugula
Contributor III
Contributor III

Dashboard slowdown when i using the Aggr function with sum function

Hi community,

I want calculate the cost per mile and cost per weight and cost per pallet. I achieved the my result but dashboard slowdown.

This is the scenario.                

ShipmentMilesAmountPalletsWeightServiceCustomerNameCarrierNameModeChargeGroup
74577782681359.112611623LH Fuel SurchargeRockwell AutomationRockwell InternationalTruckloadFuel
74577782681502611623Stop OffRockwell AutomationRockwell InternationalTruckloadAccessorial
7457778268185.012611623LTL Fuel SurchargeRockwell AutomationRockwell InternationalTruckloadFuel
745777826811875.342611623Consol LinehaulRockwell AutomationRockwell InternationalTruckloadTransportation
74577782681739.222611623Consol PickupRockwell AutomationRockwell InternationalTruckloadTransportation
7593211268138.06114778LTL Fuel SurchargeRockwell AutomationRockwell InternationalTruckloadFuel
75932112681192.17114778LH Fuel SurchargeRockwell AutomationRockwell InternationalTruckloadFuel
75932112681346114778Consol PickupRockwell AutomationRockwell InternationalTruckloadTransportation
7593211268150114778Stop OffRockwell AutomationRockwell InternationalTruckloadAccessorial
759321126811061.77114778Consol LinehaulRockwell AutomationRockwell InternationalTruckloadTransportation

     Here i want same shipment has different rates with different services but same mile, weight and Pallets.

So i need sun up the Amount of distinct shipment, miles, Weight and Pallets.

My Expressions like this:

Cost per miles --> Sum ({<Mode = {'TruckLoad'}> }Amount)/ sum({<Mode = {'TruckLoad'}> }aggr(Miles, Shipment))

Cost per Weight --> Sum (Amount)/Sum(aggr(Weight, Shipment))

Cost per Pallet -->  sum(Amount)/sum(aggr(Pallets, Shipment))


Here i have different mode are there. so applied mode condition.

Please anybody suggest 

Thanks,

ASHOK

jaganadamdavi3sawhitfieldhicvinieme12

14 Replies
Kushal_Chawda

Cost per miles --> (359.11 + 50 + 85.01+ 1875.34 + 739.22) / 2681 = 1.1595225

Sum ({<Mode = {'TruckLoad'}> }Amount)/Sum ( TOTAL <Shipment>{<Mode = {'TruckLoad'}> } distinct Miles)


Cost per Weight --> (359.11 + 50 + 85.01+ 1875.34 + 739.22) / 11623 = 0.26745934


Sum (Amount)/Sum ( TOTAL <Shipment> distinct Weight )


Cost per Pallet -->  (359.11 + 50 + 85.01+ 1875.34 + 739.22) / 26 = 119.564615


Sum (Amount)/Sum ( TOTAL <Shipment> distinct Pallet )


ashokpaladugula
Contributor III
Contributor III
Author

We cannot apply distinct on miles, weight  or pallets. Because different may have same number of miles then it cannot come sum up the value. so result become wrong.

Kushal_Chawda

Please share one example of the same.

ashokpaladugula
Contributor III
Contributor III
Author

ShipmentMilesAmountPalletsWeightServiceCustomerNameCarrierNameModeChargeGroup
74577782681359.112611623LH Fuel SurchargeRockwell AutomationProTrans InternationalTruckloadFuel
74577782681502611623Stop OffRockwell AutomationProTrans InternationalTruckloadAccessorial
7457778268185.012611623LTL Fuel SurchargeRockwell AutomationProTrans InternationalTruckloadFuel
745777826811875.342611623Consol LinehaulRockwell AutomationProTrans InternationalTruckloadTransportation
74577782681739.222611623Consol PickupRockwell AutomationRockwell InternationalTruckloadTransportation
7501508403018.01122641LTL Fuel SurchargeRockwell AutomationRockwell InternationalTruckloadFuel
75015084030527.58122641Consol LinehaulRockwell AutomationRockwell InternationalTruckloadTransportation
75015084030101.03122641LH Fuel SurchargeRockwell AutomationRockwell InternationalTruckloadFuel
7501508403050122641Stop OffRockwell AutomationRockwell InternationalTruckloadAccessorial
75015084030163.74122641Consol PickupRockwell AutomationRockwell InternationalTruckloadTransportation
7531529299816.11121567LTL Fuel SurchargeRockwell AutomationRockwell InternationalTruckloadFuel
75315292998140.05121567Consol PickupRockwell AutomationRockwell InternationalTruckloadTransportation
75315292998107.08121567LH Fuel SurchargeRockwell AutomationRockwell InternationalTruckloadFuel
7531529299850121567Stop OffRockwell AutomationRockwell InternationalTruckloadAccessorial
75315292998559.2121567Consol LinehaulRockwell AutomationRockwell InternationalTruckloadTransportation
7593211268138.06114778LTL Fuel SurchargeRockwell AutomationRockwell InternationalTruckloadFuel
75932112681192.17114778LH Fuel SurchargeRockwell AutomationRockwell InternationalTruckloadFuel
75932112681346114778Consol PickupRockwell AutomationRockwell InternationalTruckloadTransportation
7593211268150114778Stop OffRockwell AutomationRockwell InternationalTruckloadAccessorial
759321126811061.77114778Consol LinehaulRockwell AutomationRockwell InternationalTruckloadTransportation

Here suppose if we take distinct of miles or weight or pallets you will get following

miles - 2681, 4030 and 2998

Pallets - 26,12 and 11

Weight - 11623,2641 and 4778, right.

Then

if we calculate the Cost per mile for all shipments as follows

CPM = Sum(Amount)/ Sum(Miles) (i.e sum up amount of all rows / sum up individual shipments miles )

          = (359.11+50+85.01+1875.34+739.22+18.01+527.58+101.03+50+163.74+16.11+140.05+107.08+50+559.2+38.06+192.17+346+50+1061.77)/(2681+4030 +2998 + 2681) = 0.526995

          = 6529.48/12390 = 0.526995

but as per  you query we get following result

CPM = Sum(Amount)/ Sum(Miles)

        =

(359.11+50+85.01+1875.34+739.22+18.01+527.58+101.03+50+163.74+16.11+140.05+107.08+50+559.2+38.06+192.17+346+50+1061.77)/(2681+4030 +2998) => 0.526995

          = 6529.48/9709 => 0.672518 but this wrong right?

hope you will understand what i'm expecting.

anyway thanks once again.

Thanks

ASHOK

swuehl
MVP
MVP

Have you considered creating a dimensional table for Shipments with its attributes like Miles, Pallets, Weight, one record per shipment, and linking this table to your cost fact table by Shipment ID?

This should return correct aggregates without the need for advanced aggregation.