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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

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
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.