0

Link to table

Hi All,

I am trying mimic the behaviour of Report using Apex and Lightning component. I am able to get subtotal and grandtotal result using GROUP BY ROLLUP(). However I cannot query more that 3 field which are not aggregated. I have 8-9 other fields to show along with subtotal and grandtotal of 4 columns.

I have created a map of records which I have to show on page and there is an aggregated query. Could anybody suggest how to get all these in a wrapper class? I cannot use Report Builder for this because I have to divide the subtotal with a fix value and show below the subtotal.

1 Answers1

0

You should be able to do what you need with report-level formula.

Create a summary or matrix report (I've picked "Case history"), you should see a new option in the sidebar menu (well, might look bit different in Lightning but you get the idea hopefully)

enter image description here

Drop that formula on the report and it should work pretty neat

enter image description here

Leave a comment under my post if you think this doesn't work for you and you still need code. (would be good to edit your post and include a code sample so we get better idea though)

eyescream
  • 18,088
  • 2
  • 34
  • 46
  • Hello @eyescream: this shows only grandtotal.I wanted calculations at sub record level to group similar records based on a unique Id . Looks like this isn't possible through reports. I have added the logic in js controller to achieve this. Thanks for your help :) – user10268395 Sep 08 '18 at 06:37
  • No, you should be able to do it at group levels too, check "where will this formula be displayed". Well of course if your report is extra crazy... Post your query maybe, there might still be way to do it in pure SOQL if not report – eyescream Sep 08 '18 at 14:00