Report Nested Column

Hello everyone,

Im creating a custom report in that trying to create a column which have sub column inside that column.Anyone have already done this before ?

Im sharing the code for creating the columns as well.

def get_columns(self):
	columns = [
		{
			"label": _("Account"),
			"fieldname": "account",
			"fieldtype": "Data",
			"width": 405,
			"height":400,
		}
	]

	for company in self.filters.get("company"):
		columns += [
        {
            "label": _(company),
            "fieldname": f"{company}_header",
            "fieldtype": "Data",
            "width": 120,
            "height": 200,
            "options": "Hidden", 
        },
        {"label": _(f"Opening Debit ({company})"), "fieldname": f"{company}_opening_debit", "fieldtype": "Currency", "width": 120},
        {"label": _(f"Opening Credit ({company})"), "fieldname": f"{company}_opening_credit", "fieldtype": "Currency", "width": 120},
        {"label": _(f"Debit ({company})"), "fieldname": f"{company}_debit", "fieldtype": "Currency", "width": 120},
        {"label": _(f"Credit ({company})"), "fieldname": f"{company}_credit", "fieldtype": "Currency", "width": 120},
        {"label": _(f"Closing Debit ({company})"), "fieldname": f"{company}_closing_debit", "fieldtype": "Currency", "width": 120},
        {"label": _(f"Closing Credit ({company})"), "fieldname": f"{company}_closing_credit", "fieldtype": "Currency", "width": 120},
		]

	return columns

I want to show only two column in my report one is ACCOUNT and Other is COMPANY which is dynamic column as per the selction of multiselect company filter its create dynamic column of company.

Now i want to add sub columns within the COMPANY column like debit,credit,opening debit, opening credit ,etc (Please check the attached image)

Thank You in advance…

To create a custom report with columns and sub-columns in ERPNext, as shown in your image, you need to use a format that supports nested headers. Unfortunately, the standard report column configuration in ERPNext does not natively support hierarchical columns directly. #CMIIW

However, you can achieve it easily by using frappe insights and make it pivot table

1 Like