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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
MR3110
Regular Visitor

Reverse Xlookup in PowerBI

Hi , I need an assitance over the functions similar to Reverse Xlookup.

Two tables given and I want Rollno in table2 as per latest Date pick the roll no for the corresponding email. I need to add this function as calculated columns. 

 

Table-1

DateEmailRollNO
12-04-2023priyanka.aura02@gmail.com23FMG01071
13-04-2023vinrajhealth@gmail.com23FMG03093
13-04-2023dusarivasavi@gmail.com23FMG02334
14-04-2023kalyani.pedapatnapu@gmail.com

23

FMG02183

14-04-2023patukurirajeswari.2@gmail.com

23FMG

04059

19-04-2023sunandachowdary09@gmail.com23FMG03152
17-04-2023priyanka.aura02@gmail.com23FMG04221
17-04-2023vinrajhealth@gmail.com23FMG04120
17-04-2023priyanka.aura02@gmail.com22FMG10082
17-04-2023priyanka.aura02@gmail.com23FMG01315
17-04-2023vinrajhealth@gmail.com23FMG03226
17-04-2023dusarivasavi@gmail.com22FMG12561

 

Table-2

EmailRollNo
priyanka.aura02@gmail.com23FMG01315
vinrajhealth@gmail.com 
dusarivasavi@gmail.com 
kalyani.pedapatnapu@gmail.com 
patukurirajeswari.2@gmail.com 
sunandachowdary09@gmail.com 
1 ACCEPTED SOLUTION
mark_endicott
Super User
Super User

@MR3110 - You have 3 different RollNo's for priyanka.aura02@gmail.com on the same date, so it is unclear what the criteria for choosing between them is. However, looking at your results, I'm going to assume you would like the last value for that date, in which case you need to add an Index column to Table1 in Power Query. 

 

Transform Data >> Add Column >>Index Column >> From 1

 

mark_endicott_0-1724254833897.png

After this your table will look like this:

mark_endicott_1-1724254907202.png

Hit "close and apply", then you can add a calculated column to Table2 with the DAX below:

RollNo = 
VAR _email = Table2[Email]
VAR max_date = CALCULATE( MAX( Table1[Date] ), Table1[Email] = _email)
VAR max_index = CALCULATE( MAX( Table1[Index] ), Table1[Email] = _email)

RETURN
CALCULATE( MAX( Table1[RollNO] ), Table1[Date] = max_date && Table1[Index] = max_index )

 

Evidence this works: 

mark_endicott_2-1724255067310.png

 

If this works for you, please accept as the solution so others can find it. 

 

View solution in original post

3 REPLIES 3
mark_endicott
Super User
Super User

@MR3110 - You have 3 different RollNo's for priyanka.aura02@gmail.com on the same date, so it is unclear what the criteria for choosing between them is. However, looking at your results, I'm going to assume you would like the last value for that date, in which case you need to add an Index column to Table1 in Power Query. 

 

Transform Data >> Add Column >>Index Column >> From 1

 

mark_endicott_0-1724254833897.png

After this your table will look like this:

mark_endicott_1-1724254907202.png

Hit "close and apply", then you can add a calculated column to Table2 with the DAX below:

RollNo = 
VAR _email = Table2[Email]
VAR max_date = CALCULATE( MAX( Table1[Date] ), Table1[Email] = _email)
VAR max_index = CALCULATE( MAX( Table1[Index] ), Table1[Email] = _email)

RETURN
CALCULATE( MAX( Table1[RollNO] ), Table1[Date] = max_date && Table1[Index] = max_index )

 

Evidence this works: 

mark_endicott_2-1724255067310.png

 

If this works for you, please accept as the solution so others can find it. 

 

Thank You, it works well

Mohamed23
New Member

 

To achieve this in Excel, you can use a combination of the XLOOKUP and MAXIFS functions, or use FILTER in combination with INDEX and MATCH. Since you want to find the RollNo based on the latest date for each email in Table-2, here's a step-by-step guide:

Steps:

  1. Create a helper column in Table-1:

    • Create a new column in Table-1 to combine Email and Date.
    • Example formula: =A2 & "|" & B2 (assuming Date is in column A and Email is in column B).
    • Find the latest Date for each Email:

      • In Table-2, use the MAXIFS function to find the latest date for each email.
      • Example formula: =MAXIFS(Table1[Date], Table1[Email], A2) (assuming Email in Table-2 is in column A).
      • Use XLOOKUP to find the RollNo for the latest Date:

        • Now, use the XLOOKUP function to get the RollNo based on the latest Date and Email combination.
        • Example formula: =XLOOKUP(MAXIFS(Table1[Date], Table1[Email], A2), Table1[Date], Table1[RollNo]).
        • Apply the formula to Table-2:

          • Drag down the formula in Table-2 to fill in the RollNo for each email.

            Example Formula for Table-2:

            Assuming your columns are as follows:

            • Table-1: Date (A), Email (B), RollNo (C)
            • Table-2: Email (A), RollNo (B)

              You can use this formula in Table-2, Column B (RollNo):

               

              excel
              Copy code
              =INDEX(Table1[RollNo], MATCH(1, (Table1[Email]=A2) * (Table1[Date]=MAXIFS(Table1[Date], Table1[Email], A2)), 0))
               

              Explanation:

              • MAXIFS(Table1[Date], Table1[Email], A2): Finds the latest date for the email in A2.
              • MATCH(...): Matches the combination of the latest date and the email to find the correct row.
              • INDEX(Table1[RollNo], ...): Fetches the RollNo corresponding to the matched row.

                Important:

                • Make sure to press Ctrl+Shift+Enter after typing the formula if you are using an older version of Excel that requires array formulas.

                  This method will give you the latest RollNo for each email in Table-2 based on the most recent date from Table-1.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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