Support » Plugin: Calculated fields for ACF » Round down to nearest 1000?

• Resolved worldtravlr

(@worldtravlr)

Love this plugin! Thanks so much!

I can’t for the life of me figure out how to round down to the nearest 1000 can you help?

and still can’t seen to get the formula. Here is my non-rounded formula:

sum(charity_donations.donation_amount)

Can you help? Thanks so much!

Viewing 3 replies - 1 through 3 (of 3 total)
• Plugin Author wundermatics

(@wundermatics)

Hi,

To round to the nearest 1000, you can use this formula:

sum(charity_donations.donation_amount / 1000) * 1000

For a value of 12345, this will give you:

Step 1: 12345 / 1000 => 12.345
Step 2: round(1.2345) => 12
Step 3: 12 * 1000 => 12000

Plugin Author wundermatics

(@wundermatics)

…and after reading your question again, I realize you want to round DOWN to the nearest 1000. This means that you should use the function “floor”:

floor(sum(charity_donations.donations_amount) / 1000) * 1000

For a value of 12345, this will give you:

Step 1: 12345 / 1000 => 12.345
Step 2: round(1.2345) => 12
Step 3: 12 * 1000 => 12000