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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Rathod
Frequent Visitor

Return second lookup value instead of first value

Hi All,

Could someone please assist me in retrieving the second lookup value instead of the first one? Here are the details:

Table Name: Roles_EmailID


Rathod_1-1724731351066.png


When the user "abcd@gmail.com" logs in, it should return the value "superuser@gmail.com", but it is currently returning "test@gmail.com".

Here is my DAX 

VAR _getRoles = IF(CALCULATE (
FIRSTNONBLANK (Roles_EmailID[Email_IDS], 1 ),
FILTER ( ALL ( Roles_EmailID ), Roles_EmailID[RolesEmailid] = USERPRINCIPALNAME())) = "superuser@gmail.com" ,
TRUE(),
[RolesEmailid] = USERPRINCIPALNAME())

RETURN

_getRoles




2 ACCEPTED SOLUTIONS
rajendraongole1
Super User
Super User

Hi @Rathod -The rank must correctly differentiate between the different email IDs associated with each RolesEmailid.

 

rajendraongole1_0-1724743555549.png

 

create a measure:

SecondEmailID =
CALCULATE(
    FIRSTNONBLANK(abcdef[Email_IDS], 1),
    FILTER(
        abcdef,
        abcdef[RolesEmailid] = USERPRINCIPALNAME() &&
        abcdef[EmailRank] = 2
    )
)

rajendraongole1_1-1724743607649.png

Verify that the value returned by USERPRINCIPALNAME() matches exactly with the values in the RolesEmailid column.

 

Hope this helps

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





View solution in original post

Hi Gautam,

 

Thanks, its working fine

View solution in original post

6 REPLIES 6
BeaBF
Super User
Super User

@Rathod Try with:

 

Measure =
VAR _getRoles =
    CALCULATE (
        FIRSTNONBLANK (
            Roles_EmailID[Email_IDS],
            1
        ),
        FILTER (
            ADDCOLUMNS(
                FILTER ( ALL ( Roles_EmailID ), Roles_EmailID[RolesEmailid] = USERPRINCIPALNAME()),
                "Rank", RANKX(FILTER(ALL(Roles_EmailID), Roles_EmailID[RolesEmailid] = EARLIER(Roles_EmailID[RolesEmailid])), Roles_EmailID[Email_IDS], , DESC)
            ),
            [Rank] = 2
        )
    )

RETURN
_getRoles
 
BeaBF_0-1724743846651.png

 

if it's ok please accept my answer as solution.

 

BBF

rajendraongole1
Super User
Super User

Hi @Rathod -The rank must correctly differentiate between the different email IDs associated with each RolesEmailid.

 

rajendraongole1_0-1724743555549.png

 

create a measure:

SecondEmailID =
CALCULATE(
    FIRSTNONBLANK(abcdef[Email_IDS], 1),
    FILTER(
        abcdef,
        abcdef[RolesEmailid] = USERPRINCIPALNAME() &&
        abcdef[EmailRank] = 2
    )
)

rajendraongole1_1-1724743607649.png

Verify that the value returned by USERPRINCIPALNAME() matches exactly with the values in the RolesEmailid column.

 

Hope this helps

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Hi Rajendra,

Sorry, its working fine. thank you so much

Hi Rajendra,

Thanks for your swift response, i tried with your dax but unfortunatly getting below error

Rathod_0-1724743921400.png

 

 

bhanu_gautam
Super User
Super User

@Rathod , You can try using RANKX for this 

 

VAR _getRoles =
CALCULATE (
FIRSTNONBLANK ( Roles_EmailID[Email_IDS], 1 ),
FILTER (
ADDCOLUMNS (
FILTER ( ALL ( Roles_EmailID ), Roles_EmailID[RolesEmailid] = USERPRINCIPALNAME() ),
"Rank", RANKX ( FILTER ( ALL ( Roles_EmailID ), Roles_EmailID[RolesEmailid] = USERPRINCIPALNAME() ), Roles_EmailID[Email_IDS], , ASC, DENSE )
),
[Rank] = 2
)
)

RETURN
_getRoles




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Hi Gautam,

 

Thanks, its working fine

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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