I have an excel from where I have to
- Calculates the total sales for each region(central, east, west)
- Displays, in a message box, the region with the most sales and the region with the least sales, with the corresponding sales amounts
I have an excel from where I have to
Total sales Calculation is not coming correct and no msg box is getting displayed with most and least sales.
|
For find the total sales please try this,
Create a datatable using build datatable with two columns region and total,
The Outdttable will contains the regions total sales ,write this excel and test it.
Outdttable = (From row in dtTable.asenumerable
Group row by k = row("Region").tostring into grp = group
Let sum = grp.sum(function(x) Cdbl(x("Total").tostring))
Let ra = new object() {grp(0)("Region"),sum}
select Outdttable.rows.add(ra)).copytodatatable
Now for find the max and min values put this in message box,
For max value ,
Outdttable.select("[Total] = '" +
Outdttable.asenumerable.max(function(row) cdbl(row("Total"))).tostring + "'")(0)("Region").tostring
For min value ,
Outdttable.select("[Total] = '" +
Outdttable.asenumerable.min(function(row) cdbl(row("Total"))).tostring + "'")(0)("Region").tostring
Didn’t test this please test and let me know if anything required.
Thanks
Thankyou,i will try and will surely let you know
Happy to hear @Dimple_Mandal Please mark it is solution and close the thread, so it will helpful to others when they search the same query…
Thanks
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.