logo

Warning: The forum is now for consultation only. Please use GitHub Discussions to post any questions or comments.


Welcome Guest ! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
markus.fueger  
#1 Posted : Tuesday, August 31, 2021 2:51:07 PM(UTC)
markus.fueger

Rank: Newbie

Groups: Registered
Joined: 8/31/2021(UTC)
Posts: 3
Germany

Hello,

I´m new at SealReport. I've successfully built some reports, but I stuck at the Total Percent.

I want to have the percentage of the values of the Total-Line, not a sum or average from the percentage column.

Does anyone has an idea to solve this?

Thx Markus
epf  
#2 Posted : Tuesday, August 31, 2021 4:20:27 PM(UTC)
epf

Rank: Administration

Groups: Administrators
Joined: 12/20/2013(UTC)
Posts: 1,209
Switzerland

Thanks: 14 times
Was thanked: 205 time(s) in 198 post(s)
If you are using the calculation options to get the percentage of the Totals columns is not a sum or average, it is calculated with the total values.

In attachement is a sample report having a task that again performs the calculation on the result table, you can check that the values are the same is you enable or disable the task...
Calculation.srex (7kb) downloaded 13 time(s).
markus.fueger  
#3 Posted : Wednesday, September 1, 2021 5:59:21 AM(UTC)
markus.fueger

Rank: Newbie

Groups: Registered
Joined: 8/31/2021(UTC)
Posts: 3
Germany

Hi and thanks for the fast answer!

Hmm, this sample i´ve seen already. But i want to do something like this:

Example Report
epf  
#4 Posted : Wednesday, September 1, 2021 9:55:49 AM(UTC)
epf

Rank: Administration

Groups: Administrators
Joined: 12/20/2013(UTC)
Posts: 1,209
Switzerland

Thanks: 14 times
Was thanked: 205 time(s) in 198 post(s)
I have enhanced the sample 13 to calculate the difference in %

It is done in the Cell Script of the Amount element:
Code:
@{
	//Calculate the diffence in %
	ResultCell cell=Model;
	ReportElement element = cell.Element;
	ReportModel reportModel = element.Model;
	Report report = reportModel.Report;
    if (!cell.IsTitle && cell.IsTotal && cell.ContextRow > 0 && cell.ContextCol == 3)
	{
		var value1 = cell.ContextTable[cell.ContextRow,cell.ContextCol-2].DoubleValue;
		var value2 = cell.ContextTable[cell.ContextRow,cell.ContextCol-1].DoubleValue;
        if (value1 != null && value2 != null) {
            cell.FinalValue = string.Format("{0:N2} %", 100*(value2 - value1)/value1);
            if (value2 - value1 < 0)
            {
                cell.FinalCssStyle = "font-weight:bold;color:red";
            }        
        }
        else {
            cell.Value = null; 
        }
	}
    if (cell.ContextRow == 0 && cell.IsTitle && cell.IsTotal)
	{
		cell.Value = "Difference";
	}
}



You may adapt this for your report.

13-Sales comparison per month.srex (9kb) downloaded 3 time(s).
markus.fueger  
#5 Posted : Wednesday, September 1, 2021 10:53:20 AM(UTC)
markus.fueger

Rank: Newbie

Groups: Registered
Joined: 8/31/2021(UTC)
Posts: 3
Germany

Thats it! Learned a lot.

Thank you so much!
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.