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
Ivancito111
Resolver I
Resolver I

Help with a LOOKUPVALUE

Hello, sorry to bother you and thank you for taking the time to read my problem.
Also excuse my English, I am using DeepL Translator.

Well let's start. Today I was asked to use LOOKUPVALUE to search for a specific data, but if it doesn't find a data, search with another formula. For this I use the following data.

 

LeadsV2

SuuborigeneMailDate

The Rock 1127@gmail.com23-12-2021 11:00:00
The Rock 2127@gmail.com22-12-2021 12:00:00
The Rock 3127@gmail.com23-12-2021 10:58:12
The Rock 4131@gmail.com02-12-2021 12:00:00
The Rock 5131@gmail.com03-12-2021 13:00:00
The Rock 6140@gmail.com12-12-2021 14:00:00
The Rock 7141@gmail.com13-12-2021 14:00:00
The Rock 8142@gmail.com14-12-2021 14:00:00
The Rock 9143@gmail.com15-12-2021 14:00:00
The Rock 10144@gmail.com16-12-2021 14:00:00
The Rock 11145@gmail.com17-12-2021 14:00:00

 

modelov2

SuborigenWelcome GUID

123La calle 123
125La calle 125
126La calle 126
128La calle 128
129La calle 129
131La calle 131
132La calle 132
133La calle 133
134La calle 134
135La calle 135
136La calle 136

 

TodoIntranet

lead_pilotcliente_mailOrigen Lead

123123@gmail.comLa calle 123
124124@gmail.com 
125125@gmail.comLa calle 125
126126@gmail.comLa calle 126
127127@gmail.com 
128128@gmail.comLa calle 128
129129@gmail.comLa calle 129
130130@gmail.com 
131131@gmail.comLa calle 131
132132@gmail.comLa calle 132
133133@gmail.comLa calle 133

 

In my attempt to do so, I logged in to get data from the table modelov2, and this is the code and the result

 

 

Origen Lead = 
var __suborigen = 
    LOOKUPVALUE( modelov2[Welcome GUID],
                'modelov2'[Suborigen],
                'TodoIntranet'[lead_pilot])

var __email = 
    LOOKUPVALUE('LeadsV2'[Suuborigen],
                'LeadsV2'[eMail],
                'TodoIntranet'[cliente_mail])


return __suborigen

 

 

Ivancito111_0-1640704075762.png

The idea is that when the variable __suborigin is blank, it searches in the variable __email, but every time I try to test the variable __email I get the error that it has more than one data.

 

Ivancito111_1-1640704180266.png

 

I understand the error, I checked in the LeadsV2 table and the data is repeated, but with different date, is there any way to take the first time, that is, the oldest date of the record.

 

Ivancito111_2-1640704727940.png

As you can see there are 3 records with the same email, but I need the oldest one.
It should be noted that there are times when the difference is of hours, that is, they are the same day but one was made before the other.

 

Any kind of help would be important to me.

Thank you for everything.

Ivancito

1 ACCEPTED SOLUTION
parry2k
Super User
Super User

@Ivancito111 or you can have small version of this:

 

Origen Lead = 
var __suborigen = 
    LOOKUPVALUE( modelov2[Welcome GUID],
                'modelov2'[Suborigen],
                'TodoIntranet'[lead_pilot])

return 
IF ( __suborigen == BLANK(),
   CALCULATE ( MAX ( 'LeadsV2'[Suuborigen] ), TOPN ( 1, Filter ( 'LeadsV2', 'LeadsV2'[eMail] = 'TodoIntranet'[cliente_mail] ), 'LeadsV2'[Date], DESC ) ) ,
   __suborigen 
)

 

Follow us on LinkedIn

 

Learn about conditional formatting at Microsoft Reactor

My latest blog post The Power of Using Calculation Groups with Inactive Relationships (Part 1) (perytus.com) I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

 

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

4 REPLIES 4
parry2k
Super User
Super User

@Ivancito111 Sounds good. Glad it worked out. Cheers!!

 

Follow us on LinkedIn

 

Learn about conditional formatting at Microsoft Reactor

My latest blog post The Power of Using Calculation Groups with Inactive Relationships (Part 1) (perytus.com) I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

 

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

parry2k
Super User
Super User

@Ivancito111 or you can have small version of this:

 

Origen Lead = 
var __suborigen = 
    LOOKUPVALUE( modelov2[Welcome GUID],
                'modelov2'[Suborigen],
                'TodoIntranet'[lead_pilot])

return 
IF ( __suborigen == BLANK(),
   CALCULATE ( MAX ( 'LeadsV2'[Suuborigen] ), TOPN ( 1, Filter ( 'LeadsV2', 'LeadsV2'[eMail] = 'TodoIntranet'[cliente_mail] ), 'LeadsV2'[Date], DESC ) ) ,
   __suborigen 
)

 

Follow us on LinkedIn

 

Learn about conditional formatting at Microsoft Reactor

My latest blog post The Power of Using Calculation Groups with Inactive Relationships (Part 1) (perytus.com) I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

 

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Hi, thank you very much for your reply, this was the only way that worked for me. That's right, as I needed the minor date first, I changed it from DESC to ASC.

 

Ivancito111

parry2k
Super User
Super User

@Ivancito111 try this

 

Origen Lead = 
var __suborigen = 
    LOOKUPVALUE( modelov2[Welcome GUID],
                'modelov2'[Suborigen],
                'TodoIntranet'[lead_pilot])

return 
IF ( __suborigen == BLANK(),
   VAR __table = CALCULATETABLE ( 'LeadsV2', TREATAS ( VALUES ('TodoIntranet'[cliente_mail] ), 'LeadsV2'[eMail] ) )
   VAR __maxDate = MAXX ( __table, [Date] )
   RETURN MAXX ( FILTER ( __table , [Date] = __maxDate), [Suuborigen] ),
   __suborigen 
)

 

Follow us on LinkedIn

 

Learn about conditional formatting at Microsoft Reactor

My latest blog post The Power of Using Calculation Groups with Inactive Relationships (Part 1) (perytus.com) I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

 

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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.