Sending emails conditionally based on totals in SSRS reports

swanand bagve 1 Reputation point
2021-02-26T10:51:55.687+00:00

We have an SSRS reports like below

CompanyA

Currency Amount
GBP 100
USD 70
Total <> in GBP

CompanyB

Currency Amount
GBP 200
USD 10
Total <> in GBP
..
..
..

With many comapnies and if the Total is below some value then we need to email respective company representatives.
What is the easiest way to achieve this ?

SQL Server Reporting Services
SQL Server Reporting Services
A SQL Server technology that supports the creation, management, and delivery of both traditional, paper-oriented reports and interactive, web-based reports.
2,913 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Olaf Helper 44,301 Reputation points
    2021-02-26T15:34:48.817+00:00

    If you have Enterprise Edition, then you can use the feature Data-Driven Subscriptions

    Otherwise you have to modify the subscription related SQL Server Agent job to send the mail only when the condition in mind is fulfilled.

    0 comments No comments

  2. Joyzhao-MSFT 15,576 Reputation points
    2021-03-01T02:09:33.537+00:00

    Hi @swanand bagve ,
    As Olaf said, driving subscriptions is a good choice.
    Please create one table in the database to store the subscribers, such as Tablesubscribers. This table has two columns: Actualsubscribers and Nullsubscribers.
    In the Data-driven, please reference below T-SQL query.

    if (condition) ---{Example:You want the total is below some value}  
    select Actualsubscribers as subscribers from Tablesubscribers  
    else  
    select Nullsubscribers as subscribers from Tablesubscribers.  
    

    When the subscribers is NULL, the subscription status will be like “Done: 1 processed of 1 total; 1 errors.”, but it will not affect the other following delivery action.

    Additionally, there is another one work-around: you can replace the NULL value with one uncorrelated subscriber, such as your email account. However, if you using one invalid email account or un-existing email account, such as: “abcdefg” or aaaaaaa@Karima ben .com, the status will be “Done: 1 processed of 1 total; 0 errors.”. But you will receive one Undeliverable mail from you smtp server.
    Best Regards,
    Joy


    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.