Hi kana250688,
To get the desired result, you need to use the same steps explained in the following link.
Now remove the Price column and change the Item column expression with Price.
The use the SUM with Group By to get the data from database.
SQL
SELECT [CATEGORY1]
,[CATEGORY2]
,[PRICE]
,SUM([QTY]) [QTY]
FROM [ITEM]
GROUP BY [CATEGORY1], [CATEGORY2], [PRICE]
Report Design
Refer the following code.
Namespaces
Imports System.Data.SqlClient
Imports Microsoft.Reporting.WinForms
Code
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Dim dsCustomers As Customers = GetData()
Dim datasource As New ReportDataSource("Customers", dsCustomers.Tables(0))
Me.ReportViewer1.LocalReport.DataSources.Clear()
Me.ReportViewer1.LocalReport.DataSources.Add(datasource)
Me.ReportViewer1.RefreshReport()
End Sub
Private Function GetData() As Customers
Dim constr As String = "Data Source=.\SQL2022;Initial Catalog=Samples;UID=sa;PWD=pass@123;"
Using con As New SqlConnection(constr)
Using cmd As New SqlCommand("SELECT [CATEGORY1]
,[CATEGORY2]
,[PRICE]
,SUM([QTY]) [QTY]
FROM [ITEM]
GROUP BY [CATEGORY1], [CATEGORY2], [PRICE]")
Using sda As New SqlDataAdapter()
cmd.Connection = con
sda.SelectCommand = cmd
Using dsCustomers As New Customers()
sda.Fill(dsCustomers, "DataTable1")
Return dsCustomers
End Using
End Using
End Using
End Using
End Function
Screenshot