Hi Everyone,
Is it possible to retrieve the timezone of a Power BI report user?
I’ve tried using TimeZone.Current
, but it always returns Western Europe Standard Time, which I assume is the timezone where the Power BI Service is located.
Thanks for help
Roberto
Hi @Roberto
Using DataMentor/EDNA AI tools built within the EDNA Learning Portal. You can find a solution to your problem.
Here what comes up on DataMentor:
Retrieving the user’s timezone directly in Power BI is not straightforward because Power BI does not natively support capturing user environment details such as timezone.
However, you can consider a workaround using Power Automate or by custom embedding of Power BI reports within an application where you can pass user context to the report. Here are the approaches:
Approach 1: Using Power Automate
- Create a Power Automate Flow:
- Trigger the flow when the user views the report.
- Capture the user’s timezone using appropriate connectors (e.g., Office 365 Users connector).
- Pass the Captured Timezone to Power BI:
- Once you have the user’s timezone from the flow, you can pass it to Power BI using the Power BI REST API or updating a dataset directly.
Approach 2: Custom Embedding
- Embed Report in a Web Application:
- Create a web application to embed your Power BI report.
- Capture the user’s timezone using JavaScript (
Intl.DateTimeFormat().resolvedOptions().timeZone
).
- Pass Timezone to Power BI Report:
- Use Power BI JavaScript API to pass the timezone as a filter or parameter to the embedded report.
Example Using Power Automate (High-Level Steps):
- Create a Manual Triggered Flow in Power Automate.
- Add Get User Profile (V2) action to retrieve the user’s details.
- Extract the timezone from the user’s profile.
- Update a Power BI dataset/table with the timezone information using Power BI actions or Azure SQL connections.
Example Using JavaScript in Custom Embedding:
<script src="https://cdnjs.cloudflare.com/ajax/libs/powerbi-client/2.10.0/powerbi.min.js"></script>
<script>
// Capture user's timezone
let userTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
// Configuration for embedding the report
let embedConfiguration = {
type: 'report',
id: 'your-report-id',
embedUrl: 'your-embed-url',
accessToken: 'your-access-token',
...,
settings: {
...
filters: [
{
$schema: "http://powerbi.com/product/schema#advanced",
target: {
table: "YourTable",
column: "TimezoneColumn"
},
operator: "In",
values: [userTimeZone]
}
]
}
};
// Embed the report
let reportContainer = document.getElementById('reportContainer');
powerbi.embed(reportContainer, embedConfiguration);
</script>
These approaches require additional setup but will allow you to tailor the experience based on the user’s timezone.
Please give DataMentor a try!!!
I hope this helps.
Keith
1 Like