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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
userdata
Helper IV
Helper IV

How to lookupvalue in second table where text value picks earlier date that is not null

Table 1                                                                          Table 2

date |  mean                                                                  date | std

27.4     34                                                                        24.4    c

12.3     12                                                                        12.3   blank

                                                                                         10.3 x

                                                                                           9.3  b

 

 

 

output i want to see:

 

date |  mean  | std                                                                

27.4     34        c                                                               

12.3     12        x

 

there are two different table 1 and 2 and what i need to do is lookup if date in first table is 12.3 then i need to check in table 2 if there is a std for 12.3 if not i have to take the latest value that is not blank, in this case it would be x.

How would I do that in DAX

1 ACCEPTED SOLUTION
v-yadongf-msft
Community Support
Community Support

Hi @userdata ,

 

I created two tables the same as you.

 

Table1:

vyadongfmsft_0-1659694840315.png

 

Table2:

vyadongfmsft_1-1659694840316.png

 

Please create a new column and try following DAX:

std = 
VAR lookup = LOOKUPVALUE('table2'[std],'table2'[date],'table1'[date])
RETURN
IF(
    NOT ISBLANK(lookup),lookup,
    MAXX(
        FILTER('table2','table2'[date]),
        'table2'[std])
        )

 

Then you can get result you want.

vyadongfmsft_2-1659694840318.png

 

Best Regards,

Yadong Fang

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-yadongf-msft
Community Support
Community Support

Hi @userdata ,

 

I created two tables the same as you.

 

Table1:

vyadongfmsft_0-1659694840315.png

 

Table2:

vyadongfmsft_1-1659694840316.png

 

Please create a new column and try following DAX:

std = 
VAR lookup = LOOKUPVALUE('table2'[std],'table2'[date],'table1'[date])
RETURN
IF(
    NOT ISBLANK(lookup),lookup,
    MAXX(
        FILTER('table2','table2'[date]),
        'table2'[std])
        )

 

Then you can get result you want.

vyadongfmsft_2-1659694840318.png

 

Best Regards,

Yadong Fang

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

@v-yadongf-msft Thanks so much for this!! You are a herooo!

userdata
Helper IV
Helper IV

@amitchandak  thanks for this . I tried to use the calculated column but I get the same value for std but it should change based on date.  The values do not show correctly

userdata_0-1659549602852.png

 

Anyone else who can help on this? How do I create a lookup for the latest date that is not null from table 2? Thanks!

amitchandak
Super User
Super User

@userdata , New column in table one

 

col  =

var _min = minx(filter(Table2, table2[Date] <= table1[Date]) , Table2[Date])

return

minx(filter(Table2, table2[Date] =_min) , Table2[std])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

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.