Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
I'm building a custom visual and I need to identify the logged in user's email. How can I do it? Thanks
Hi skakara,
Do you mean USERNAME Function? It can return the UPN of the user using the report.
Thanks for your reply Sam!!
No, I'm not looking for the USERNAME() DAX function. I'm actually looking for a simple way to get the username from my custom visual's JavaScript code.
When I view the page source of the PowerBI webpage, I see the below global JavaScript object taht actually has the username.
But I'm not 100% sure if I can rely on that object, so that it might not change in future breaking my code.
var powerbi = {
session : {
userInfo: {
name: 'xxxxx@xxxxx.com',
givenName: xxxxx,
surname: xxxxx,
puid: xxxxx,
uoid: xxxxx,
alternateEmail: ''
}
}
};
Hi skakara,
Currently, playing with powerbi.session.userInfo in custom visual may not be reliable. See https://github.com/Microsoft/PowerBI-visuals/issues/412.
Power BI Custom Visuals API does not provide user name or user email.
We recommend to use DAX function to get user's email.
Ignat Vilesov,
Software Engineer
Microsoft Power BI Custom Visuals
Hey @v-viig ,
is this still the case or are there other ways to get the username/-email within the visual and without passing it from outside the visual?
Regards
Lucmax
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
7 | |
7 | |
3 | |
2 | |
2 |
User | Count |
---|---|
6 | |
5 | |
4 | |
4 | |
4 |