Hello @community,
I have developed script reports in my custom app. Now i want to show total and avg of value fetched on based on filter in script report. How can i show this in last.
Thanks,
Hardik Gadesha
Hello @community,
I have developed script reports in my custom app. Now i want to show total and avg of value fetched on based on filter in script report. How can i show this in last.
Thanks,
Hardik Gadesha
I already Did this, that’s why it shown in my script report. But how to get value there ? That’s my query.
Total
is only shown for "Currency", "Int", "Float", "Percent", "Data"
fieldtype.
Please check your field types of columns in script report.
Thanks @Sangram for your reply.
Yeah, it’s working now. i tried Data field type but did not work for that, It’s working for Int. But how can i show avg as like sum in bottom. I want to show Avg of column for other reports.
Add Total Row
is by default functionality of framework for the report.
Please check this,
you can write your script for Average Row
Yes, I will write it but how to show this in bottom ?
Append it to final data of report. Go through query_report.py
. Check how they add Total Row
.
Hello,
How can i find avg of column and show it to bottom of the report ?
Here is my python script. @Sangram
`from future import unicode_literals
import frappe
from frappe import _
def execute(filters=None):
columns = get_column()
data = get_data(filters)
return columns,data
def get_column():
return [(“Ballmill No”) + “:Data:100”,(“Ballmill Date”) + “100”,(“Kanta No”) + “:Data:100”, (“By Whom”) + “::100”,(“Time”) + “::100”, (“Dencity”)+“:Float:100”, (“Viscocity”) + “:Float:100”,(“Residue”) + “:Float:100”,(“Grinding”) + “::100”,(“Remarks”) + “::180”]
def get_data(filters):
if filters.get(“from_date”,“to_date”):
from_date = filters.get(“from_date”)
to_date = filters.get(“to_date”)
ballmill_DVRG = frappe.db.sql(“”"
select obj1.ballmill_name, obj1.date, obj1.weigh_bridge, obj2.by_whom,obj2.time,obj2.density, obj2.viscosity, obj2.residue, obj2.grinding,obj2.remarks from tabBallmill
obj1, tabCT1
obj2 where (obj1.weigh_bridge = obj2.parent) and (obj1.date between ‘%s’ and ‘%s’) ORDER BY obj1.date ASC,obj2.idx ASC;“”" %(from_date,to_date), as_list=1)
return ballmill_DVRG`
I want avg of density, viscosity, residue at bottom of it’s particular column.
Thanks,
Hardik Gadesha
ballmill_DVRG
this is your result.
add your logic here. Calculate the average of columns you want. Then add calculated Average Column
to it and return the result.
Check query_report.py
Thanks,
Sangram