Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
robm135
Helper I
Helper I

Being alerted to scheduled refresh failures

Running Jan 2021 PBI RS

 

What is a good way to get proactivitly alerted to a scheduled refresh stopping? 

Sometimes a scheduled refresh just stops happening and users have to let me know. Once I click 'refresh now' the schedule refreshing begins again.

 

If PBI RS doesn't natively do this has anyone worked out a decent workaround?

 

1 ACCEPTED SOLUTION
CDavies
Resolver I
Resolver I

Hi

 

Use this query  (connected to your PBI report server) in an SSRS report and schedule the SSRS to email out the failures:

 

WITH cte_LastRefresh AS
(

SELECT 
       MAX(SubscriptionHistoryID) AS SubscriptionHistoryID
       ,SubscriptionID
FROM dbo.SubscriptionHistory 
WHERE [Status] = 2
GROUP BY SubscriptionID

) 

SELECT 
          c.Name                                      as [Report Name]
      --rs.scheduleid
      ,c.path                                  as [Report Path]  
      ,sub.[Description]                 as [Schedule Name]
      --,sub.[LastStatus]                      as [Last Status]
         ,SUBSTRING(sh.Details,CHARINDEX('Message":"',sh.Details)+10,200)+ '...' AS [Error Detail]
      --CASE WHEN sub.[InactiveFlags] = 0 THEN 'Enabled'
             --     WHEN sub.[InactiveFlags] = 128 THEN 'Disabled'
             --     ELSE 'Other' 
             --END  as [Enabled]
      --,sub.[EventType]                       as "Event Type"
      ,CONVERT(Varchar(17),sub.[LastRunTime],113) as [Last Run Time]
         ,SUBSTRING(u_own.UserName,CHARINDEX('\',u_own.UserName)+1,10) as [Created by]
         ,SUBSTRING(u_mod.[UserName],CHARINDEX('\',u_mod.[UserName])+1,10) as [Modified by]
         ,CASE WHEN jsch.next_run_date = 0 THEN '-'
               ELSE Convert(Varchar(17),msdb.dbo.agent_datetime(jsch.next_run_date, jsch.next_run_time),113) 
             END as [Next Run Time]
        --,CASE c.[Type] WHEN 2 THEN 'SSRS'
             --                  WHEN 5 THEN 'Data Source'
             --                  WHEN 7 THEN 'Report Part'
             --                  WHEN 8 THEN 'Shared Dataset'
             --                  When 13 Then 'Power BI'
             --                  ELSE 'Other'
             -- END AS "ReportType"
             ,sub.LastStatus
  FROM [dbo].[Subscriptions] sub
       INNER JOIN dbo.[Catalog] c ON sub.report_oid = c.itemid
       INNER JOIN [dbo].Users u_own ON c.CreatedByID = u_own.UserID
       INNER JOIN [dbo].Users u_mod ON c.ModifiedByID = u_mod.UserID
       INNER JOIN dbo.ReportSchedule rs ON sub.SubscriptionID = rs.SubscriptionID
       INNER JOIN cte_LastRefresh lr ON rs.SubscriptionID = lr.SubscriptionID
       INNER JOIN dbo.SubscriptionHistory sh ON lr.SubscriptionHistoryID = sh.SubscriptionHistoryID
       LEFT OUTER JOIN msdb.dbo.sysjobs j ON CAST(rs.ScheduleID AS VARCHAR(100)) = j.name
       LEFT OUTER JOIN msdb.dbo.sysjobschedules jsch ON j.job_id = jsch.job_id
WHERE 1=1
       AND sub.LastStatus like '%failed%'
       AND jsch.next_run_date <> 0
       AND Convert(smalldatetime,msdb.dbo.agent_datetime(jsch.next_run_date, jsch.next_run_time)) > getdate() 
order by 2

 

View solution in original post

5 REPLIES 5
CDavies
Resolver I
Resolver I

Hi

 

Use this query  (connected to your PBI report server) in an SSRS report and schedule the SSRS to email out the failures:

 

WITH cte_LastRefresh AS
(

SELECT 
       MAX(SubscriptionHistoryID) AS SubscriptionHistoryID
       ,SubscriptionID
FROM dbo.SubscriptionHistory 
WHERE [Status] = 2
GROUP BY SubscriptionID

) 

SELECT 
          c.Name                                      as [Report Name]
      --rs.scheduleid
      ,c.path                                  as [Report Path]  
      ,sub.[Description]                 as [Schedule Name]
      --,sub.[LastStatus]                      as [Last Status]
         ,SUBSTRING(sh.Details,CHARINDEX('Message":"',sh.Details)+10,200)+ '...' AS [Error Detail]
      --CASE WHEN sub.[InactiveFlags] = 0 THEN 'Enabled'
             --     WHEN sub.[InactiveFlags] = 128 THEN 'Disabled'
             --     ELSE 'Other' 
             --END  as [Enabled]
      --,sub.[EventType]                       as "Event Type"
      ,CONVERT(Varchar(17),sub.[LastRunTime],113) as [Last Run Time]
         ,SUBSTRING(u_own.UserName,CHARINDEX('\',u_own.UserName)+1,10) as [Created by]
         ,SUBSTRING(u_mod.[UserName],CHARINDEX('\',u_mod.[UserName])+1,10) as [Modified by]
         ,CASE WHEN jsch.next_run_date = 0 THEN '-'
               ELSE Convert(Varchar(17),msdb.dbo.agent_datetime(jsch.next_run_date, jsch.next_run_time),113) 
             END as [Next Run Time]
        --,CASE c.[Type] WHEN 2 THEN 'SSRS'
             --                  WHEN 5 THEN 'Data Source'
             --                  WHEN 7 THEN 'Report Part'
             --                  WHEN 8 THEN 'Shared Dataset'
             --                  When 13 Then 'Power BI'
             --                  ELSE 'Other'
             -- END AS "ReportType"
             ,sub.LastStatus
  FROM [dbo].[Subscriptions] sub
       INNER JOIN dbo.[Catalog] c ON sub.report_oid = c.itemid
       INNER JOIN [dbo].Users u_own ON c.CreatedByID = u_own.UserID
       INNER JOIN [dbo].Users u_mod ON c.ModifiedByID = u_mod.UserID
       INNER JOIN dbo.ReportSchedule rs ON sub.SubscriptionID = rs.SubscriptionID
       INNER JOIN cte_LastRefresh lr ON rs.SubscriptionID = lr.SubscriptionID
       INNER JOIN dbo.SubscriptionHistory sh ON lr.SubscriptionHistoryID = sh.SubscriptionHistoryID
       LEFT OUTER JOIN msdb.dbo.sysjobs j ON CAST(rs.ScheduleID AS VARCHAR(100)) = j.name
       LEFT OUTER JOIN msdb.dbo.sysjobschedules jsch ON j.job_id = jsch.job_id
WHERE 1=1
       AND sub.LastStatus like '%failed%'
       AND jsch.next_run_date <> 0
       AND Convert(smalldatetime,msdb.dbo.agent_datetime(jsch.next_run_date, jsch.next_run_time)) > getdate() 
order by 2

 

Does this works other DBMS other than SRSS? Like PostgreSQL?

champion! that's works a treat 

AnkitKukreja
Super User
Super User

Hi! @robm135 

 

Your schedule refresh stops after 4 failures and 2 months of inactivity.

 

https://docs.microsoft.com/en-us/power-bi/connect-data/refresh-scheduled-refresh#schedule-refresh

AnkitKukreja_1-1643728753438.png

AnkitKukreja_0-1643728729140.png

 

You can check the usage metrics report by clicking on the ellipsis (3 dots) beside your report that will give you idea if the report was ideal or not.

 

I hope this helps. 

 

For Power BI trainings or support dm or reach out to me on LinkedIn.
If my response has successfully addressed your question or concern, I kindly request that you mark this post as resolved. Additionally, if you found my assistance helpful, a thumbs-up would be greatly appreciated.

Thanks,
Ankit Kukreja
www.linkedin.com/in/ankit-kukreja1904
https://topmate.io/ankit_kukreja

thanks, but I'm referring to the powerbi report server. I know in cloud you can set an email alert for scheduled failure but this isn't an option for report server (at least for Jan 2021 which I'm running) 

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.