Can I use two values in same row to create a new value and display it as a third column?

Jaspersoft Community 'Read-Only' as of July 8, 2022

Transition to New TIBCO Community Just Weeks Away

You can still search, review wiki content, and review discussions in read-only mode. Please email community@tibco.com with questions or issues requiring TIBCO review or response.

Hello all,

I am supposed to create a report of a store where I need to calculate which items are sold more based on the total stock of items and total sold items and create a third column in report in percentage.
Is it possible to achieve this in Jasper report or I need to do something else ?

The report will look like as follow: I am able to fetch the item no, total in stock and total sold and I need to calculate the sold % based on total in stock and total sold.

pathfinder2104.work's picture
Joined: Feb 27 2014 - 8:52pm
Last seen: 7 years 11 months ago

I am using List element to display this data.

pathfinder2104.work - 8 years 3 months ago

2 Answers:

For Jaspersoft Studio, I recommend looking at chapter 9, Variables, of the JSS User Guide.

http://community-static.jaspersoft.com/sites/default/files/docs/jasperso...

You can create a variable and define an expression, which would be the calculation you want. Another possible calculation for the percent sold would be 100*total_sold/(total_in_stock + total_sold). There are problems with the calc suggested in previous answer, for example, if you sold everything, so total_in_stock = 0, you would get infinity for the percent sold, instead of 100%.

elizam's picture
10863
Joined: Mar 5 2012 - 9:19am
Last seen: 1 year 11 months ago

Thank you elizam for this answer ..... :) :) :) :) :)

pathfinder2104.work - 8 years 3 months ago

Hey there, thank you for answering the question, Now I have another requirement of calculating the average of the fourth column that I have created by finding the percentage. Can I do it? How ? Any pointers would help thank you.

pathfinder2104.work - 8 years 3 months ago

Yes, you can do it with JasperReports and with JasperReports Server in AdHoc reports.

JJust create a text field.

hozawa's picture
131794
Joined: Apr 24 2010 - 4:31pm
Last seen: 3 years 3 weeks ago

Hi, I am a novice in Jasper report can you please explain in brief how can I achieve it ?

pathfinder2104.work - 8 years 3 months ago

Need to carry out the calculation using the two fields of total in stock and total sold. (total in stock means when the shop opens at that time what ever was the stock) and this report is to be generated at the end of the day.) calculation would be 100*total_sold/total_in_stock using this calculation I want to display the precentage.

pathfinder2104.work - 8 years 3 months ago
Feedback
randomness