13 Replies Latest reply: Feb 13, 2012 11:10 PM by rohitsant87

# Calculating percentage value in a chart

Hi,

I have one bar chart with two dimensions

1) MonthYear (which has values like Jan 2010, Feb 2010, etc)

2) Type (which has values 'A', 'B' and 'C')

The expression shows the count of books for selected date range (I have two calender objects for that) for the respective monthyear and type.

It is working fine, but what I need to display is percentage of each type of books for respective months.

For e.g. in Jan 2010; there are total 500 books, out of which 100 are of type A, 200 each of type B and C.

I want to display for Jan 2010, for type A, 20%, for type B and C 40% each. This should vary as per the count of books for other months.

My expression is

=count({<Date = {">=\$(vFromDate) <=\$(vToDate)"}>} BookID)

(As I am having personnel edition of qlikview; I will not be able to open any external .qvw file)

• ###### Calculating percentage value in a chart

=count({<Date = {">=\$(vFromDate) <=\$(vToDate)"}>} BookID) / count({<Date = {">=\$(vFromDate) <=\$(vToDate)"}>}    Total BookID)

Check Show in Percent(%) in number tab for the exp

• ###### Calculating percentage value in a chart

Hi,

This expression gives me wrong results. I have 36 books of type 'A' and 23 books of type 'B' in the month of Jan 2010. So th total books  = 59. So my requirement is that while showing percentage for Jan 2010, it should be based on 59. i.e.type 'A' books = 61.01% and 38.93%. But after implementing the solution given by you, it is giving results as type 'A' books = 27% and type 'B' books = 17% which is wrong.

• ###### Calculating percentage value in a chart

Hi,

If you have a field in the name month year then,

Try with this expression,

=Count(Books)/Count(Total <MonthYear> Books)

Check the in percentage option in the number tab of the chart properties.

Hope it helps

Celambarasan

• ###### Re: Calculating percentage value in a chart

Hi,

This expression gives me wrong results. I calculated a field in script as MonthYear = monthname(Date). I have 36 books of type 'A' and 23 books of type 'B' in the month of Jan 2010. So th total books  = 59. So my requirement is that while showing percentage for Jan 2010, it should be based on 59. i.e.type 'A' books = 61.01% and 38.93%. But after implementing the solution given by you, it is giving results as type 'A' books = 2% and type 'B' books = 1% which is wrong.

• ###### Calculating percentage value in a chart

Hi,

Try the following expession

=Count({<Date = {">=\$(vFromDate) <=\$(vToDate)"}>} BookID) /

Count({<Date = {">=\$(vFromDate) <=\$(vToDate)"}>} Total <MonthYear> Books)

Regards,

Jagan

• ###### Re: Calculating percentage value in a chart

Hi,

This expression gives me wrong results. I calculated a field in script as MonthYear = monthname(Date). I have 36 books of type 'A' and 23 books of type 'B' in the month of Jan 2010. So th total books  = 59. So my requirement is that while showing percentage for Jan 2010, it should be based on 59. i.e.type 'A' books = 61.01% and 38.93%. But after implementing the solution given by you, it is giving results as type 'A' books = 2% and type 'B' books = 1% which is wrong.

• ###### Calculating percentage value in a chart

Hi,

Can you attach the Qlikview file.  It would be useful to solve.

Regards,

Jagan.

• ###### Re: Calculating percentage value in a chart

Hi,

Please check the attached file for solution.

Hope this helps you.

Regards,

Jagan.

• ###### Re: Calculating percentage value in a chart

Hi,

I cant attach qlikview file. Also I can't open your file as I have

personnel edition of qlikview.

On Mon, Feb 13, 2012 at 1:35 PM, jagan mohan <

• ###### Re: Calculating percentage value in a chart

Hi,

Can you able to attach sample data and image of the chart that shows wrong %?

Celambarasan

• ###### Calculating percentage value in a chart

Hi,

The content in the attached file is

MonthYear, BookID, Count

Jan 2010, A, 45

Jan 2010, B, 56

Jan 2010, C, 54

Feb 2010, A, 21

Feb 2010, B, 42

Feb 2010, C, 32

];

In Straight table

I used MonthYear and BookID as dimensions.

Expression : =Sum(Count)/Sum(Total<MonthYear>Count)

Hope this helps you.

Regards,

Jagan.

• ###### Calculating percentage value in a chart

Hello

Not sure I understand, but what would I do (TOTAL-A) / A and (TOTAL-B) / B and percentage checkbox

I hope that helps