Forum Discussion
Incorrect totals between different years
i am trying to multiply the (data[cost/lbs] from 3 years against only the (sum(data[2023 LBS]) but something is incorrect with the filters so I am getting incorrect result for 2024 and 2025.
The Values should be:
2024: 0.09841927 x 148,457,498.59 = 14,611,078.63
2025: 0.09367710 x 148,457,498.59 = 13,907,067.94
Current forumla:
Hi GVallentgoed ,
With the following formula I am able to get to the desired result:sumxtripcost = SUMX( VALUES(Data[Destination Name]), VAR LbsCost = DIVIDE( SUM(Data[Trip Cost]), SUM(Data[BOL LBS]) ) VAR TotalLbs = CALCULATE( SUM(Data[2023 LBS]), ALL(Data[Lates Delivery].[Year]) ) RETURN LbsCost * TotalLbs )The results for this are:The difference between the 2024 and 2025 expected totals shared earlier seem to be caused by decimal differences. Did you calculate them using the 4 decimal cost/lbs?
This works! I had to make 1 adustment to your solution though because my master data set has 'Destination Names' that appear in some years and not others. So, i changed the VALUES filter to "Lates Delivery [Year]. years with missing Destinations Names are not ignored.
sumxtripcost =SUMX(VALUES(Data[Latest Delivery].[Year]),VAR LbsCost =DIVIDE(SUM(Data[Trip Cost]),SUM(Data[BOL LBS]))VAR TotalLbs =CALCULATE(SUM(Data[2023 LBS]),ALL(Data[Latest Delivery].[Year]))RETURNLbsCost * TotalLbs)
14 Replies
- rajendraongole1Super User
Hi GVallentgoed - i guess, issue is with the ALLSELECTED filter inside the CALCULATE function.
check the below modified calculation:
TotalCost =
VAR BaseLBS_2023 = CALCULATE( SUM(Data[2023 LBS]), ALL(Data[Year]) )RETURN
SUMX(
VALUES(Data[Destination Name]),
DIVIDE( SUM(Data[Trip Cost]), SUM(Data[BOL LBS]) ) * BaseLBS_2023
)Hope this works, please check
- GVallentgoedHelper II
incorrect result
- GVallentgoedHelper II
Heres a small sample data set
Rate Year Trip Cost SCAC TP Load Number Lates Delivery Destination Name BOL LBS BOL CF 2023 LBS 2024 LBS 2023 Rates 2024 Rates 2025 LBS 2025 Rates 2023 $ 4,796.67 LLLE 850425645 2023-01-05 05:00 SOBEYS QUEBEC - TERREBONNE 11,268.69 1244.87 11,268.69 $ 4,796.67 2023 $ 1,308.08 TNXU 851274159 2023-01-27 06:00 CORE-MARK CALGARY 7,556.79 353.44 7,556.79 $ 1,308.08 2023 $ 3,472.17 TNXU 851526682 2023-01-30 12:00 COSTCO DEPOT 76 12,772.50 1013.33 12,772.50 $ 3,472.17 2023 $ 2,157.07 TNXU 851582572 2023-02-02 06:00 CORE-MARK CALGARY 11,191.01 479.14 11,191.01 $ 2,157.07 2023 $ 5,024.31 TNXL 851974808 2023-02-07 09:00 COSTCO DEPOT 76 16,150.00 1493.33 16,150.00 $ 5,024.31 2023 $ 5,835.07 PGPS 853552495 2023-02-24 18:00 SOBEYS QUEBEC - TERREBONNE 21,428.53 1043.21 21,428.53 $ 5,835.07 2023 $ 1,243.21 TNXU 873618756 2024-01-03 05:00 CORE-MARK CALGARY 6,356.44 275.48 6,356.44 $ 1,243.21 2023 $ 1,259.00 LLLE 873865681 2024-01-03 14:00 SOBEYS QUEBEC - TERREBONNE 18,408.65 1348.47 18,408.65 $ 1,259.00 2024 $ 2,387.46 TNXU 873874630 2024-01-08 08:00 COSTCO DEPOT 76 11,513.44 960 11,513.44 $ 2,387.46 2024 $ 2,853.41 TNXU 875038422 2024-01-29 05:00 CORE-MARK CALGARY 13,760.51 603.65 13,760.51 $ 2,853.41 2024 $ 2,157.67 TNXU 875598901 2024-02-02 06:00 CORE-MARK CALGARY 12,150.21 624.73 12,150.21 $ 2,157.67 2024 $ 3,564.64 TNXU 875613027 2024-02-05 12:42 COSTCO DEPOT 76 28,415.63 2346.67 28,415.63 $ 3,564.64 2024 $ 2,780.14 LLLE 876247038 2024-02-06 05:40 SOBEYS QUEBEC - TERREBONNE 21,515.89 1001.13 21,515.89 $ 2,780.14 2025 $ 1,259.00 LLLE 897358220 2025-01-02 10:50 SOBEYS QUEBEC - TERREBONNE 15,998.39 722.06 15,998.39 $ 1,259.00 2025 $ 2,889.40 TNXU 897216331 2025-01-08 05:30 CORE-MARK CALGARY 13,934.06 686.61 13,934.06 $ 2,889.40 2025 $ 2,478.82 TNXU 898527166 2025-01-31 08:00 COSTCO DEPOT 76 12,860.31 865.77 12,860.31 $ 2,478.82 2025 $ 3,062.63 TNXU 898874898 2025-02-03 09:00 COSTCO DEPOT 76 15,889.13 1493.33 15,889.13 $ 3,062.63 2025 $ 3,640.26 TNXU 899187722 2025-02-07 05:30 CORE-MARK CALGARY 17,555.04 808.02 17,555.04 $ 3,640.26 2025 $ 1,204.89 LLLE 900442941 2025-02-21 10:50 SOBEYS QUEBEC - TERREBONNE 13,629.93 694.23 13,629.93 $ 1,204.89
- DanielW_Advocate I
Hi GVallentgoed ,
With the following formula I am able to get to the desired result:sumxtripcost = SUMX( VALUES(Data[Destination Name]), VAR LbsCost = DIVIDE( SUM(Data[Trip Cost]), SUM(Data[BOL LBS]) ) VAR TotalLbs = CALCULATE( SUM(Data[2023 LBS]), ALL(Data[Lates Delivery].[Year]) ) RETURN LbsCost * TotalLbs )The results for this are:The difference between the 2024 and 2025 expected totals shared earlier seem to be caused by decimal differences. Did you calculate them using the 4 decimal cost/lbs?
- GVallentgoedHelper II
This works! I had to make 1 adustment to your solution though because my master data set has 'Destination Names' that appear in some years and not others. So, i changed the VALUES filter to "Lates Delivery [Year]. years with missing Destinations Names are not ignored.
sumxtripcost =SUMX(VALUES(Data[Latest Delivery].[Year]),VAR LbsCost =DIVIDE(SUM(Data[Trip Cost]),SUM(Data[BOL LBS]))VAR TotalLbs =CALCULATE(SUM(Data[2023 LBS]),ALL(Data[Latest Delivery].[Year]))RETURNLbsCost * TotalLbs)- v-sgandrathiCommunity Support
Hi GVallentgoed,
I'm glad you found a solution and resloved the query. Thank you very much for sharing here.
Kindly mark your reply as the accepted solution so that others in the community can find it quickly.
Thankyou for connecting with Microsoft Community Forum.