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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

Check out the June 2024 Power BI update to learn about new features.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.