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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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])

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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

Top Solution Authors