1

I try to write an Arcade expression in dashboard indicator, the expression has 4 if statements but only the first two statements are works the code is below:

############################################

var`enter code here`ar kmillion = 10000000;
var million = 1000000;
var k100 = 100000;

var name_km = Left($datapoint["sum_VALUE"],2) 
var name_m  = Left($datapoint["sum_VALUE"],1) 
var name_k100 = Left($datapoint["sum_VALUE"],3) 
var name_k99 =  Left($datapoint["sum_VALUE"],2)

if ($datapoint["sum_VALUE"] >= kmillion) {
    return {
        topText: 'اجمالي عدد التلاميذ',
        topTextColor: '#a80000',
        topTextOutlineColor: '',
        topTextMaxSize: 'small',
        middleText: name_km,
        middleTextColor: '',
        middleTextOutlineColor: '',
        middleTextMaxSize: 'large',
        bottomText: 'مليون تلميذ',
        iconName:'icon1',
        iconAlign:'left',
        iconColor:'',
        iconOutlineColor:''
        
    }
}

else if ($datapoint["sum_VALUE"] >= million < kmillion  ) {
    return{ 
        topText: 'اجمالي عدد التلاميذ',
        topTextColor: '#a80000',
        topTextOutlineColor: '',
        topTextMaxSize: 'small',
        middleText: name_m,
        middleTextColor: '',
        middleTextOutlineColor: '',
        middleTextMaxSize: 'large',
        bottomText: '2مليون تلميذ',
        iconName:'icon1',
        iconAlign:'left',
        iconColor:'',
        iconOutlineColor:''
        
    }
}

else {
    return {
        topText: 'اجمالي عدد التلاميذ',
        topTextColor: '#a80000',
        topTextOutlineColor: '',
        topTextMaxSize: 'small',
        middleText: name_k100,
        middleTextColor: '',
        middleTextOutlineColor: '',
        middleTextMaxSize: 'large',
        bottomText: 'ألف تلميذ',
        iconName:'icon1',
        iconAlign:'left',
        iconColor:'',
        iconOutlineColor:''
        
    }
}
0

1 Answer 1

1

Your code will never hit the final "else" condition. You should use this conditional instead for the second "else if"

else if ($datapoint["sum_VALUE"] >= million  ) {

The code already checked if the value is greater or equal to kmillion in the first if statement.

If you need to check whether a value is between two numbers in an if statement, you have to use something like

if (value >= 10 and value < 20)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.