表达式运算
概述
表达式运算:在报表中进行公式运算。
应用场景
如下图所示,简单展示数据

Preview
示例说明
数据准备
在数据面板中添加数据集,可选择Json数据集和API服务数据集。Json数据集输入如下图所示:
[{"OrderID":10248,"CustomerId":"VINET","CompanyName":"山泰企业","OrderDate":"1996/7/4 0:00:00","Freight":32.38,"ProductID":42,"ProductName":"糙米","UnitPrice":9.8,"Quantity":10,"Discount":0,"Amount":98,"DiscountAmt":0,"NetAmount":98},
{"OrderID":10248,"CustomerId":"VINET","CompanyName":"山泰企业","OrderDate":"1996/7/4 0:00:00","Freight":32.38,"ProductID":72,"ProductName":"酸奶酪","UnitPrice":34.8,"Quantity":5,"Discount":0,"Amount":174,"DiscountAmt":0,"NetAmount":174},
{"OrderID":10248,"CustomerId":"VINET","CompanyName":"山泰企业","OrderDate":"1996/7/4 0:00:00","Freight":32.38,"ProductID":17,"ProductName":"猪肉","UnitPrice":14,"Quantity":12,"Discount":0,"Amount":168,"DiscountAmt":0,"NetAmount":168},
{"OrderID":10249,"CustomerId":"TOMSP","CompanyName":"东帝望","OrderDate":"1996/7/5 0:00:00","Freight":11.61,"ProductID":14,"ProductName":"沙茶","UnitPrice":18.6,"Quantity":9,"Discount":0,"Amount":167.4,"DiscountAmt":0,"NetAmount":167.4},
{"OrderID":10249,"CustomerId":"TOMSP","CompanyName":"东帝望","OrderDate":"1996/7/5 0:00:00","Freight":11.61,"ProductID":51,"ProductName":"猪肉干","UnitPrice":42.4,"Quantity":40,"Discount":0,"Amount":1696,"DiscountAmt":0,"NetAmount":1696},
{"OrderID":10250,"CustomerId":"HANAR","CompanyName":"实翼","OrderDate":"1996/7/8 0:00:00","Freight":65.83,"ProductID":41,"ProductName":"虾子","UnitPrice":7.7,"Quantity":10,"Discount":0,"Amount":77,"DiscountAmt":0,"NetAmount":77},
{"OrderID":10250,"CustomerId":"HANAR","CompanyName":"实翼","OrderDate":"1996/7/8 0:00:00","Freight":65.83,"ProductID":51,"ProductName":"猪肉干","UnitPrice":42.4,"Quantity":35,"Discount":0.15,"Amount":1484,"DiscountAmt":222.60000884532928,"NetAmount":1261.4},
{"OrderID":10250,"CustomerId":"HANAR","CompanyName":"实翼","OrderDate":"1996/7/8 0:00:00","Freight":65.83,"ProductID":65,"ProductName":"海苔酱","UnitPrice":16.8,"Quantity":15,"Discount":0.15,"Amount":252,"DiscountAmt":37.800001502037048,"NetAmount":214.2},
{"OrderID":10251,"CustomerId":"VICTE","CompanyName":"千固","OrderDate":"1996/7/8 0:00:00","Freight":41.34,"ProductID":22,"ProductName":"糯米","UnitPrice":16.8,"Quantity":6,"Discount":0.05,"Amount":100.8,"DiscountAmt":5.0400000751018519,"NetAmount":95.76},
{"OrderID":10251,"CustomerId":"VICTE","CompanyName":"千固","OrderDate":"1996/7/8 0:00:00","Freight":41.34,"ProductID":57,"ProductName":"小米","UnitPrice":15.6,"Quantity":15,"Discount":0.05,"Amount":234,"DiscountAmt":11.700000174343586,"NetAmount":222.3},
{"OrderID":10251,"CustomerId":"VICTE","CompanyName":"千固","OrderDate":"1996/7/8 0:00:00","Freight":41.34,"ProductID":65,"ProductName":"海苔酱","UnitPrice":16.8,"Quantity":20,"Discount":0,"Amount":336,"DiscountAmt":0,"NetAmount":336}]
报表设计
将数据字段拖入A2-H2单元格,并设置为分组以及向下扩展。
在F2单元格输入公式=C2D2,在G2单元格输入公式=C2D2E2,在H2单元格输入公式=C2D2-C2D2E2
选中A1-H2单元格,点击上方工具栏-添加分组。
如下图所示

Preview
效果预览

Preview