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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Charu
Post Patron
Post Patron

How to display Username with greetings when user log in?

Hi Everyone,

 

Please let me know whether my requirement is possible in power bi service login using RLS(row level Security)

example: When I log in to the report the left side I would like to display My name with greetings.

 

Based on login time Greeting should change like Good morning,Good Afternoon,Good Evening

username greeting.PNG

2 ACCEPTED SOLUTIONS

Greeting1 = 
VAR user = USERNAME()
VAR display = LOOKUPVALUE(Table1[User],Table1[Email],user)
VAR hour = HOUR(NOW())
VAR minute = MINUTE(NOW())
VAR prefix = SWITCH(
                    TRUE(),
                    hour<12,"Good morning ",
                    hour>=12 && hour<17,"Good afternoon ",
                    "Good evening "
             )
RETURN CONCATENATE(prefix,display)

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

Hi

 

below is how I achieved the Timezone difference, timezone correct.PNGfor your reference

 

View solution in original post

8 REPLIES 8
Greg_Deckler
Super User
Super User

How about a measure in a card visual like this:

 

Greeting = 
VAR user = USERNAME()
VAR hour = HOUR(NOW())
VAR minute = MINUTE(NOW())
VAR prefix = SWITCH(
                    TRUE(),
                    hour<12,"Good morning ",
                    hour<17,"Good afternoon ",
                    "Good evening "
             )
RETURN CONCATENATE(prefix,user)

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Wow! Great @Greg_Deckler.Thank you.

 

Username() returning sara@xyz.com instead I need the name only .so I'm maintaining one column to store the list of username in each table. 

 

suppose If I have 3tables connected to the report and each table I will be having UsernameList and Email list

 

how could I pass username list column in the parameter

var User =UsernameList

 

UsernameList is the filed name in my table

 thanks in advance

 

Greeting1 = 
VAR user = USERNAME()
VAR display = LOOKUPVALUE(Table1[User],Table1[Email],user)
VAR hour = HOUR(NOW())
VAR minute = MINUTE(NOW())
VAR prefix = SWITCH(
                    TRUE(),
                    hour<12,"Good morning ",
                    hour>=12 && hour<17,"Good afternoon ",
                    "Good evening "
             )
RETURN CONCATENATE(prefix,display)

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Thanks a lot, it's working fine in desktop but once i publish to service the time is wrongly showing please help me where I'm doing mistake

 

I published on 7:39pm that is 19:39 instead it's showing 14:06

 

greeting.PNG

Have a look at this blog:

http://radacad.com/solving-dax-time-zone-issue-in-power-bi

 

But, short story is the easiest way will be to just put an offset into your hour calculation to account for your timezone difference between where you are an where Power BI is hosted.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

It's not working with Userprincipal for other user.Their name is mapped with correct email id

Greeting =
VAR user = USERPRINCIPALNAME()
VAR display = LOOKUPVALUE(Detail[Name],Detail[Email Id],user)
VAR hour = HOUR(NOW())
VAR minute = MINUTE(NOW())
VAR prefix = SWITCH(
TRUE(),
hour<12,"Good morning ",
hour>=12 && hour<17,"Good afternoon ",
"Good evening "
)
RETURN CONCATENATE(prefix/*"Welcome. "*/,display)

Hi @shoeb1359

 

If your Detail[Name] lookup values return the username then try using the USERNAME() function instead of USERPRINCIPALNAME()

Hi

 

below is how I achieved the Timezone difference, timezone correct.PNGfor your reference

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors