Create variable to count element meeting condition and ouptut to email

Stimulsoft Reports.NET discussion
Post Reply
Alex92
Posts: 8
Joined: Fri Jul 28, 2023 4:09 am

Create variable to count element meeting condition and ouptut to email

Post by Alex92 »

Hello,

I am using Stimulsoft Designer (version 2023.2.8) embedded in a .NET application.
I created a text field with a hyperlink to open and prefill an email template. I am struggling to output one of my variables (VariableA) to that email.
In that VariableA I want to count the number of returned rows in DataBand1 where a property equals a given value.

In the report GroupHeaderBand I have created a field with the expression: {CountIf(DataBand1,Property=="OK")} and it works perfectly when I generate the report.
I figured I would be able to set VariableA as type int value + Init by expression and reuse that same expression, but it does not work.

Any recommendation?

Thank you.
Lech Kulikowski
Posts: 6412
Joined: Tue Mar 20, 2018 5:34 am

Re: Create variable to count element meeting condition and ouptut to email

Post by Lech Kulikowski »

Hello,

You can use Totals.Sum() function in the read only variable and then use this variable as you need.

Thank you.
Alex92
Posts: 8
Joined: Fri Jul 28, 2023 4:09 am

Re: Create variable to count element meeting condition and ouptut to email

Post by Alex92 »

Hello,

Thanks for your answer. Do you have a step by step? I tried a few things but it did not work.

I tried something different too:
- The field with the expression {CountIf(DataBand1,Property=="OK")} is Text1.
- I figured I could assign the value of that field to my variable
- I changed the VariableA type to string, and added an End Render Event to my report and put this expression: VariableA=Text1.TextValue
Howerver it still shows nothing when I display VariableA in the report or in the prefilled email after clicking on the hyperlink.
Lech Kulikowski
Posts: 6412
Joined: Tue Mar 20, 2018 5:34 am

Re: Create variable to count element meeting condition and ouptut to email

Post by Lech Kulikowski »

Hello,

Please send us a sample report with test data that reproduces the issue for analysis.

Thank you.
Alex92
Posts: 8
Joined: Fri Jul 28, 2023 4:09 am

Re: Create variable to count element meeting condition and ouptut to email

Post by Alex92 »

Hi,

Of course, here is the mrt file. But for the sample data since it is in a database, I am not sure how to provide that.

Thanks.
Attachments
test_report.mrt
(115.69 KiB) Downloaded 171 times
Lech Kulikowski
Posts: 6412
Joined: Tue Mar 20, 2018 5:34 am

Re: Create variable to count element meeting condition and ouptut to email

Post by Lech Kulikowski »

Hello,

It is not possible to set it in the events.
You can use the Totals.Count(datasource, column) function in the ReadOnly variable, and then use this variable in the hyperlink.

Also, you can create the DataTransformation data source, in which calculates the count with the necessary condition, and then use the column of this DataTransformation in the hyperlink.

Thank you.
Post Reply