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
nicolasvc
Helper III
Helper III

Lookupvalue only returns first match

I have two tables, in the first I have a product for the first week of the month (the week is the number in the year), and in the second table I have the value of each product but for all the weeks of the year, and I need in the first Table capture the value of the product of the second in the specific week, for that I used the lookupvalue function but for some reason it only returns the first match and then pure blank, since it has the same format in the columns. What can be?

Table A

StoreProductyearmonthweek
1A202111
1B202111
1A202125
1B202125
...............

 

Table B

StoreProductyearmonthweekvalue
1A2021112000
 A202112300
..................
1A202125850
..................

 

valueTableA = lookupvalue(tableB[value], 

tableB[Store],tableA[Store],
tableB[year],tableA[year],
tableB[month],tableA[month],
tableB[week],tableA[week])

 

And it returns only 2000.

4 REPLIES 4
Greg_Deckler
Super User
Super User

@nicolasvc LOOKUPVALUE in my opinion is not reliable. Try using MAXX(FILTER(...),...) instead.


@ 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...

@Greg_DecklerThanks for the answer, but I think I need a little help, I don't know and I couldn't how to adapt the lookupvalue query using MAX and FILTER 😞

@nicolasvc Try:

valueTableA = 
  VAR __Store = tableA[Store]
  VAR __Year = tableA[year]
  VAR __Month = tableA[month]
  VAR __Week = tableA[week]
RETURN
  MAXX(FILTER(tableB, tableB[Store]=__Store && tableB[year]=__Year && tableB[month]=__Month && 
tableB[week]=__Week),tableB[value])

@ 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...
goncalogeraldes
Super User
Super User

Hello there @nicolasvc ! This looks like something I would either do with the RELATED() function or through a merge in Power Query. Why not try it this way?

 

 

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.