Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
kulasekhar
Creator
Creator

How to display two colors in barchart

Hi All,

I want display batem 25% in Purple color remaining Blue color.


please send me sample qvw.


Thanks

sekhar.

23 Replies
kulasekhar
Creator
Creator
Author

Hi Michael,

The first 25% Purple color the remaining Blue color

MichaelCapture.JPG

   Like that Michael.

Thanks

SEKHAR.

kulasekhar
Creator
Creator
Author

Hi Robert,

The first 25% Purple color the remaining Blue color

MichaelCapture.JPG

   Like that Robert.

Thanks

SEKHAR.

sunny_talwar

Something like this?

Capture.PNG

Script:

Table:

LOAD * Inline [

Dim, Value

A, 5

B, 13

C, 20

D, 10

E, 2

];

Join(Table)

LOAD Sum(Value) as TotalValue

Resident Table;

FinalTable:

LOAD Dim,

  Value,

  TotalValue,

  Value/TotalValue as PercentValue

Resident Table;

FinalTable1:

LOAD *,

  TotalPercentValue - 0.25 as TotalPercentValue1;

LOAD *,

  PercentValue + Alt(Peek('TotalPercentValue'), 0) as TotalPercentValue

Resident FinalTable

Order By Dim;

DROP Table Table, FinalTable;

All Fields of FinalTable1 in a table box object:

Capture.PNG

Bar Chart Dimension: Dim

Bar Chart Expressions:

1) =If(TotalPercentValue1 < 0, PercentValue, If(TotalPercentValue1 = Min({<TotalPercentValue1 = {'>0'}>} TOTAL TotalPercentValue1), PercentValue - TotalPercentValue1))

2) =If(TotalPercentValue1 = Min({<TotalPercentValue1 = {'>0'}>} TOTAL TotalPercentValue1), TotalPercentValue1, If(TotalPercentValue1 > 0, PercentValue))


Attaching the QVW for reference.


HTH


Best,

Sunny

Not applicable

Hi.

Can you send the sample database (excel or something). I couldn't get 25% of what

(plz send if this question is still not solved)

Anonymous
Not applicable

Hi Michael,

I guess kula sekhar is expecting X- axis first 25% is Purple colour and rest 75% in Blue colour.

Anonymous
Not applicable

Am i correct Kula Sekhar???

Digvijay_Singh

The bars are depicting some values, right? So the requirement is to show first 25% of total value( may be shown under first 1,2,2.5..bars) in purple color and rest of the total values( depicted under rest of the bars..) in blue color.

Digvijay_Singh

Great! This is working perfectly! I think change in bcgrnd color in expression may reflect the purple and blue color, cannot see the qvw as I have PE.

Would you mind explaining one thing, may be silly one, how come a single row'TotalValue'  joined to Dim of 'TABLE' without having any matching key. I think I am missing something basic here.

Join(Table)

LOAD Sum(Value) as TotalValue

Resident Table;


Thanks again, your posts r helping a lot. Take care,

sunny_talwar

Hey Digvijay I am glad you are getting to learn from me . And trust me no questions are silly. To answer your question, when there are no matching keys between the table you are joining from and the table you join to then you end up forming a Cartesian product. But for this particular case where TotalValue is just a single value it is added as a new column with one value for each of the rows.

Example:

Before Join

Dim,     Value

A,           10

B,           20

C,           30

TotalValue

60

AfterJoin

Dim,     Value,     TotalValue

A,          10,           60

B,          20,           60

C,          30,           60

I hope the above example will clarify things.

Best,

Sunny

Anonymous
Not applicable

I'm maybe a little late...

See attached solution which is purely front-end, nothing in the script to support it.  The advantage is that it is dynamic, and the 25% is defined in a variable, so it can be changed easily to any other %.

Still it doesn't work properly in some conditions, e.g. if the first value is greater than the 25%.  I'll maybe get back to clean it up, or maybe somebody else will do it before...