# QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Valued Contributor II

## How to make line color turn red when net profit amount -ve ?

Hi All

I like to make the line chart display :-

1. When the net profit amount is -ve it shown red color line.

2. when the net profit amount is +ve it shown black color line.

Now it display whole line red color.

Paul

1 Solution

Accepted Solutions
Not applicable

## Re: How to make line color turn red when net profit amount -ve ?

Hi Paul,

I think, you have to use your expression, instead of sum([NET_PROFIT)). i.e.,

if( (sum({\$<year = {">=\$(=max(year),4)"}, month = {"<=\$(=max({<year={\$(=max(year))}>} month))"}>}NET_PROFIT/\$(Columndim89)/1000)) < 0, red(), Black())

Thanks,
Vinod Kumar V

9 Replies
Valued Contributor II

## Re: How to make line color turn red when net profit amount -ve ?

Hi All

Enclosed my QV doc

Valued Contributor

## Re: How to make line color turn red when net profit amount -ve ?

Hi,

add expression at back ground color

=if(sum[net profit]<0,red(),Black())

MVP

## Re: How to make line color turn red when net profit amount -ve ?

I don't see any line (its showing no data to display) and I tried clearing out any selection and still says the same.

Valued Contributor II

## Re: How to make line color turn red when net profit amount -ve ?

Hi Sir

=if

(

sum([NET_PROFIT]<0,red(),Black()

)

)

I try above like what you said , but it still not work.

Paul

Valued Contributor

## Re: How to make line color turn red when net profit amount -ve ?

there is a formatting error in the expression you have mentioned. You have misplaced the bracket. Please refer my expression above.

Not applicable

## Re: How to make line color turn red when net profit amount -ve ?

Hi Paul,

I think, you have to use your expression, instead of sum([NET_PROFIT)). i.e.,

if( (sum({\$<year = {">=\$(=max(year),4)"}, month = {"<=\$(=max({<year={\$(=max(year))}>} month))"}>}NET_PROFIT/\$(Columndim89)/1000)) < 0, red(), Black())

Thanks,
Vinod Kumar V

Valued Contributor

## Re: How to make line color turn red when net profit amount -ve ?

also in the qvw you have attached there is no data to display in the chart as mentioned above.

You may try using Vinod Kumar's expression at background color.

Valued Contributor II

## Re: How to make line color turn red when net profit amount -ve ?

Hi Kumar

it work , thank you vey much

Not applicable

ywc