cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How do I transfer values between key figures without causing rounding issues?

ptopolewski
Explorer
0 Likes
959

Dear SAC Community,

We want to transfer values from Key Figure A with 7 decimal places to Key Figure B with 2 decimal places. Copying the data between these key figures leads to rounding errors. The data needs to be copied to Key Figure with 2 dec. places as we have to export the data to table ACDOCP in our S4 System in which the key figures are restricted to two dec. places. How can we transfer the values from key figure A to keyfigure B without getting rounding errors?

In addition, I will give you a more detailed example. In our scenario we want to distribute 5.000 equally with a 50% share to two Order numbers. In our planning story, we enter 5.000 on year 2026 and the value gets automatically allocated to the underlying periods. Here we use Key Figure A with 7 decimal places

 

OrderSumJanFebMarAprMayJunJulAugSepOctNovDec
#5000416,6666667416,66666676667416,6666667416,6666667416,6666667416,6666667416,6666667416,6666667416,6666667416,6666667416,6666667416,6666667

Now we perform the allocation with a 50% per Order nr. The 7 decimals come in handy as we won't face any rounding issues when performing the allocation.

 

OrderSumJanFebMarAprMayJunJulAugSepOctNovDec
Order12500208,315208,335208,335208,335208,335208,335208,335208,335208,335208,335208,335208,335
Order22500208,315208,335208,335208,335208,335208,335208,335208,335208,335208,335208,335208,335

In order to prepare the data for the S4 ACDOCP export, we move the values from key figure A to key figure B via a data action, which results in rounding errors.

OrderSumJanFebMarAprMayJunJulAugSepOctNovDec
Order12.499,94208,31208,33208,33208,33208,33208,33208,33208,33208,33208,33208,33208,33
Order22.499,94208,31208,33208,33208,33208,33208,33208,33208,33208,33208,33208,33208,33

Best regards

Pascal

Accepted Solutions (0)

Answers (1)

Answers (1)

spurwar
Product and Topic Expert
Product and Topic Expert
0 Likes

Try creating the below calculated measures or write a data action to convert the numbers from 7 decimal places to 2 decimal places. 


Below is a rough way to convert the data using calculated measures and can be optimised further.

 

Measure IDMeasure DescFormula
AmountOriginal Amount(7 decimal places)  
Amount_RoundAmount_RoundFLOOR([Amount]*100 )/100
Amount_ResidueAmount_Residue( [Amount]-[Amount_Round])
MonthDerive Month from Month desciptionIF([d/Period].[p/MONTHDESC] = "Jan", 1,
IF([d/Period].[p/MONTHDESC] = "Feb", 2,
IF([d/Period].[p/MONTHDESC] = "Mar", 3,
IF([d/Period].[p/MONTHDESC] = "Apr", 4,
IF([d/Period].[p/MONTHDESC] = "May", 5,
IF([d/Period].[p/MONTHDESC] = "Jun", 6,
IF([d/Period].[p/MONTHDESC] = "Jul", 7,
IF([d/Period].[p/MONTHDESC] = "Aug", 8,
IF([d/Period].[p/MONTHDESC] = "Sep", 9,
IF([d/Period].[p/MONTHDESC] = "Oct", 10,
IF([d/Period].[p/MONTHDESC] = "Nov", 11,
IF([d/Period].[p/MONTHDESC] = "Dec", 12, 0
))))))))))))
Amount_adjAdjustmnet to be postedIF([Month] <= ROUND(SUBTOTAL([Amount_Residue],[d/Period])/0.01,0), 0.01, 0)
Amount_S4Amount_S4 ( 2 decimal places)[Amount_Round]+[Amount_adj]

Example:

 TotalJanFebMarAprMayJunJulAugSepOctNovDec
Amount5000416.6667416.6667416.6667416.6667416.6667416.6667416.6667416.6667416.6666416.6666416.6666416.6666
Amount_Round4999.92416.66416.66416.66416.66416.66416.66416.66416.66416.66416.66416.66416.66
Amount_Residue0.080.00670020.00670020.00670020.00670020.00669990.00669990.00669990.00669990.00659990.00659990.00659990.0065999
Month 123456789101112
Amount_adj 0.010.010.010.010.010.010.010.010000
Amount_S45000416.67416.67416.67416.67416.67416.67416.67416.67416.66416.66416.66416.66
ptopolewski
Explorer
0 Likes

please delete this comment

ptopolewski
Explorer
0 Likes

please delete this comment

ptopolewski
Explorer
0 Likes

please delete this comment

ptopolewski
Explorer
0 Likes
Hi spurwar, thanks for your reply and ideas! I have checked it but unfortunately it is not working for me. The subtotal for the residiual amount is not determined correctly. My Amount_Residue is 0.005 for all periods and when i try to get the subtotal for Amount_Residue it shows me 0.00. The subtotal function works fine with other key figures. Could it be that the subtotal function does not work with small numbers like 0.005? Best regards Pascal