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
Anonymous
Not applicable

Error with LOOKUPVALUE

Hey everyone!

 

I have two tables. The first one looks like this:

Count (Float Type)MonthInCalendar ( Date Type)
11016.26mar. 2021
22750.6apr. 2021
24028.95may. 2021
26069.28jun. 2021

 

The second one looks like this:

 

Date (String and Int Type)

31/03/2021

30/04/2021
31/05/2021
30/06/2021

 

I am trying to create a second column in Table2 with

Column = LOOKUPVALUE('Table1'[Count],'Table1'[MonthInCalendar], Table2[Date].[Month])
But with this line I just obtain blank cells.
 
What would be the correct way to do this LOOKUPVALUE?
 
Thanks!!
1 ACCEPTED SOLUTION
v-chenwuz-msft
Community Support
Community Support

Hi @Anonymous ,

 

Please try this code to do that.

Column = 
LOOKUPVALUE (
    Table1[Count (Float Type)],
    Table1[MonthInCalendar (String Type)], FORMAT ( 'Table2'[Date (Date type)], "mmm. yyyy" )
)

 

Result:

vchenwuzmsft_0-1658823270438.png

 

 

Pbix in the end you can refer.

Best Regards

Community Support Team _ chenwu zhu

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
v-chenwuz-msft
Community Support
Community Support

Hi @Anonymous ,

 

Please try this code to do that.

Column = 
LOOKUPVALUE (
    Table1[Count (Float Type)],
    Table1[MonthInCalendar (String Type)], FORMAT ( 'Table2'[Date (Date type)], "mmm. yyyy" )
)

 

Result:

vchenwuzmsft_0-1658823270438.png

 

 

Pbix in the end you can refer.

Best Regards

Community Support Team _ chenwu zhu

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

SolomonovAnton
Super User
Super User

hello !

 

in The [Table1] table your field MonthInCalendar  has Date Type. It mean what real data in The column 'MonthInCalendar' it's not 'mar. 2021' it is '03/01/2021' or '03/15/2021' or '03/31/2021' Your formate type show it in "MM.YYYY"

so your scipt should looks like 

 

 

Column = LOOKUPVALUE('Table1'[Count],'Table1'[MonthInCalendar], Table2[Date])

 

 

 

and in The [Table2] The column [Date] should be Date type (it mean same data type as The [MonthInCalendar] field in The [Table1])

 

Anonymous
Not applicable

Hey! My bad, i wrote wrong the data types. In Table1, the datatype is String and Int, because of how I did the transformation and grouping of that table. In Table2 it is a Date type. If I use your solution it gives me the following error: 

Function 'LOOKUPVALUE' does not support comparing values of type Text with values of type Date. Consider using the VALUE or FORMAT function to convert one of the values.

 

To get the MonthInCalendar column I used this line:

= Table.AddColumn( Origen, "MonthInCalendar", each Date.ToText([Item Date], "MMM yyyy") )

 

ccastrejsan_0-1658487005510.png

 

your fields in calculate column

Column = LOOKUPVALUE('Table1'[Count],'Table1'[MonthInCalendar], Table2[Date])

should be the same type and same view so it mean for example 

'Table1'[MonthInCalendar] should be text type and format "MMM YYYY"

and 

Table2[Date]  should be text type and format "MMM YYYY"

 

 

if  I have resolved you qestion please mark topic as resolved 

if I helped you please click to give Kudos for me 🙂

PC2790
Community Champion
Community Champion

Hey @Anonymous ,

 

For LOOKUPVALUE to work, the columns from two tables should have exact match.

You should look for fuzzy matching concept in power query to cater to your requirement here.

 

How fuzzy matching works in Power Query - Power Query | Microsoft Docs

Fuzzy Matching in Power BI and Power Query; Match based on Similarity Threshold - RADACAD

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.