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

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

    Thread Starter worldtravlr

    (@worldtravlr)

    Awesome! Thank you so much! I think that would have taken me weeks to figure out it at all! šŸ™‚

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Round down to nearest 1000?’ is closed to new replies.