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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
GKJARC
Resolver I
Resolver I

Get date report last viewed

Hi everyone,

 

To improve the user experience, I've put a welcome message on the landing page of my report saying "Welcome back, [username]".
I would like the welcome message to only appear when they have not opened the report in let's say more than 72 hours.

Any ideas on how this can be done? Or can I fetch the report views timestamps somewhere so that I can use it in the welcome text measure of my report?

 

Thanks!

2 REPLIES 2
Bipin-Lala
Solution Supplier
Solution Supplier

Hi @GKJARC,

 

Accessing and fetching user report viewing logs is possible by using the Power BI Activity APIThe Power BI Activity API allows retrieving detailed activity logs related to Power BI usage, including user-level interactions such as report views, queries, dataset refreshes, and more.

 

Even we have recently deployed a Power BI Governance Dashboard in our organization which uses Power BI Activity API along with other Power BI Read-Only Admin APIs and Scanner APIs to get our Tenant's activity and catalog data. And we do get Report View logs from our dashboard. The response would look something like this - 

BipinLala_0-1711743632410.png

 

While it's possible to obtain report views timestamps for your report, several considerations need to be addressed before implementing a solution -

  • Permissions - You need to be a Power BI Admin or have an app registration that can access Power BI Read-Only Admin APIs to be able to access these activity logs. Getting such permissions may prove difficult in an organization since you are not only looking at logs for your report, but you can access logs across the entire tenant, which may require some security approval.
  • Data Freshness - Considering you manage to get access to these logs, and eventually calculate last accessed timestamp for a user accessing your specific report, you would still need to ensure that the last interaction date is up to date. For this, you may need to adjust the refresh frequency of your dataset. For example, if a user accesses the report twice within an hour, and if the report has not been refreshed, the welcome message would still appear saying that the report has not been opened in the last 72 hours. Hence the report would have to be frequently refreshed.
  • API Latency - Even if the report is frequently refreshed, we are not entirely sure how soon the latest activities are available to be fetched via the Power BI Activity API. There may be a delay for the latest events/ activities to be made available via the API and hence it needs to be taken into account as well.

I hope this provides insight and encourages collaborative efforts in finding a robust solution for your specific use case.

 

Alex_Sawdo
Helper II
Helper II

It's technically possible, and there's probably a better way to do it, but below is a powershell script our company runs nightly (using an SSIS job) to get the activity log out of Power BI and into a SQL table on-prem. You'll need to do some research yourself to get it to work, as I'm not too well versed in how it fully functions. Doing it dynamically though like you want may be much more difficult.

# Prerequisits - install Powershell Power  Bi modules
# Install-Module -Name MicrosoftPowerBIMgmt.Profile -Force
# Install-Module -Name SqlServer -Force

#Parameters
$TenantId = "INSERT YOUR TENANT HERE"
$AppId = "INSERT YOUR APPID HERE"
$Secret = "INSERT YOUR SECRET HERE"
$ErrorActionPreference = "Stop"

# 1. Login to app.power.bi with Service Prinipal
$password = ConvertTo-SecureString $Secret -AsPlainText -Force
$Creds = New-Object PSCredential $AppId, $password
try {Connect-PowerBIServiceAccount -ServicePrincipal -Credential $Creds -Tenant $TenantId}
catch {throw "Tenant login failed"}

# 2. Get Data from app.powerbi/azure for previous day
$Datum = Get-Date((get-date ).AddDays(-1))  -Format "yyyy-MM-dd"
 
$StartDate = $Datum + 'T00:00:00'
$EndDate = $Datum + 'T23:59:59'
  
$json = Get-PowerBIActivityEvent -StartDateTime $StartDate -EndDateTime $EndDate | ConvertFrom-Json
$activity = $json | Select Id, CreationTime,Workload, UserId, Activity, ItemName, WorkSpaceName, DatasetName, ReportName, WorkspaceId, ObjectId, DatasetId, ReportId, ReportType ,DistributionMethod, ConsumptionMethod
 
# 3. Insert into SQL Server Database
Write-SqlTableData -InputData $activity -ServerInstance "YOUR SQL SERVER" -DatabaseName "YOUR SQL DATABASE" -SchemaName "YOUR DATABASE SCHEMA" -TableName "YOUR TABLE" -Force

 Alternatively, there might be a premium/fabric feature that can accomplish this as well. 

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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