help with Subract array old value with new value

Welcome Forums General PowerShell Q&A help with Subract array old value with new value

Viewing 4 reply threads
  • Author
    Posts
    • #237079
      Participant
      Topics: 1
      Replies: 2
      Points: 37
      Rank: Member

      Hi all,

      i have an array

      i want to subtract 50 from 500 then update that value and continue down the list. something like this

      500-50 = 450
      450-10 = 440
      440-25 = 415
      415-60 = 355
      355-84 = 271

      i can do it manually

      Please may i ask for some guidance as to how i can do this using for statement?

      i keep failing, below is what i tried but only works for the first value.

      Thanks

      • This topic was modified 3 months ago by Mawazo51. Reason: formating
      • This topic was modified 3 months ago by Mawazo51.
    • #237082
      Participant
      Topics: 7
      Replies: 2458
      Points: 6,439
      Helping Hand
      Rank: Community MVP

      Jam, welcome to Powershell.org. Please take a moment and read the very first post on top of the list of this forum: Read Me Before Posting! You’ll be Glad You Did!.

      When you post code, error messages, sample data or console output format it as code, please.
      In the “Text” view you can use the code tags “PRE“, in the “Visual” view you can use the format template “Preformatted“. You can go back edit your post and fix the formatting – you don’t have to create a new one.
      Thanks in advance.

    • #237103
      Participant
      Topics: 1
      Replies: 2
      Points: 37
      Rank: Member

      Man i didn’t know you can subtract like that. i spent hours on this lol

      Thank you Olaf! Much appreciated. i’ve edited the post.

      I got my list \o/

    • #237106
      Participant
      Topics: 7
      Replies: 2458
      Points: 6,439
      Helping Hand
      Rank: Community MVP
    • #237160
      Participant
      Topics: 1
      Replies: 2
      Points: 37
      Rank: Member

      Thanks 🙂

Viewing 4 reply threads
  • You must be logged in to reply to this topic.