Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8515653
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:12:28+00:00 2026-06-11T05:12:28+00:00

I have the below if statement in use to compare 2 rows in the

  • 0

I have the below if statement in use to compare 2 rows in the same column in a table. I use the same block of code multiple times to perform the same calculation on different columns.

Basically, I want to have an arrow show both the movement in value between one row and the next, as well as the threshold the value falls into. So, for example, in my code below anything above 15 should be a red arrow and if the previous value was lower then the arrow should point up. I render the arrows using images called from another location later in my code, so the if statement just gives me the string for the appropriate arrow.

As I said above, I have the same block of code numerous times. The strange thing is, the output works for some variables and does’t for others; even though it’s the exact same code with the variable names replaced! It gives me the wrong are SOMETIMES for no apparent reason.

Do I have too many conditions? Is there a more efficient way to do what I’m trying to do?

Any assistance would be greatly appreciated!

Thanks,
Karl

var Arrow = " ";
if(KPI[0] > KPI[1] && KPI[0] >= 15)
{
    Arrow = "redarrowup.png";
}
else if(KPI[0] < KPI[1] && KPI[0] >= 15)
{
    Arrow = "redarrowdown.png";
}
else if(KPI[0] = KPI[1] && KPI[0] >= 15)
{
    Arrow = "redarrowflat.png";
}
else if(KPI[0] > KPI[1] && KPI[0] >= 10 && KPI[0] < 15)
{
    Arrow = "yellowarrowup.png";
}
else if(KPI[0] < KPI[1] && KPI[0] >= 10 && KPI[0] < 15)
{
    Arrow = "yellowarrowdown.png";
}
else if(KPI[0] = KPI[1] && KPI[0] >= 10 && KPI[0] < 15)
{
    Arrow = "yellowarrowflat.png";
}
else if(KPI[0] > KPI[1] && KPI[0] < 10)
{   
    Arrow = "greenarrowup.png";
}
else if(KPI[0] < KPI[1] && KPI[0] < 10)
{   
    Arrow = "greenarrowdown.png";
}
else
{
    Arrow = "greenarrowflat.png";
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T05:12:30+00:00Added an answer on June 11, 2026 at 5:12 am

    At first glance I’d say that you have an “=” where you need an “==” (or even “===”). For example

    if(KPI[0] = KPI[1] && KPI[0] >= 15)
    

    should probably be

    if(KPI[0] == KPI[1] && KPI[0] >= 15)
    

    (or even === as I said). And so forth. “=” is an assignment operator, it sets the value of KPI[0] to the value of KPI[1] and then returns that value, so you are essentially doing the following:

    KPI[0] = KPI[1];
    if(KPI[1] && KPI[0] >= 15)
    

    which I doubt is the intention. That said, as several others have already said there are better ways to structure the code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am wonder about how to update the table. I have use below two
I have the below String assignment statement String items[] = line.split(\,\,15); String fileNamet =
I have created a procedure and used the below statement inside that . select
I have a problem when trying to execute this update statement (below) using C#
I have a problem with the SQL statement detailed below. The query returns the
I have this if statement that tests for the 2 conditions below. The second
I have below snippet of code in which TestClass is extending jPanel which is
I have below code: <a href=# id=@item.Id name=vote ><img src=/Content/images/021.png style=float:left alt= /></a> which
I have below variables try to make an auto generating SQL statement in python
I have the below LINQ method that I use to create the empty EmploymentPLan

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.