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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Ope_AF
Regular Visitor

Search if a value appears in a column of an other table

Hi Everybody,

I need your help on an issue that i encountered :

 

I have two tables : Table 1 (projects are unique)

 

ProjectStatus
AM-007BAU
FM-006Terminated
AMFM-001On Going

 

Table 2 (project can appears mutliple time)

ProjectDateStatus
AM-007null 
AM-00730/08/2020 
AM-00731/08/2020 
CT-036null 
CT-03630/08/2020 

 

I need to fill the status colum of the second table. In order to do this i have rules :

- if date = null then i search on the first table if the project is in and if it is i copy the status of the project of the table 1 in the table 2. If the project is not in the table 1 then i put the status "N/A"

- else if the date is outdated i put the status "Delivered" else the status "On Going"

For example in the exemple above it would give this :

ProjectDateStatus
AM-007nullBAU
AM-00730/08/2020Delivered
AM-00731/08/2020On Going
CT-036nullN/A
CT-03630/08/2020On Going

 

i've tried to put a custom column with this formula : if Table2[Date]=null then if Table2[Project] = Table1[Project] then Table2[Status] = Table1[Status] else "N/A" else "To be fixed"
Actually it doesn't works, all the column got the value "N/A". I don't even know what do power querry did when i do "if Table2[Project] = Table1[Project]" 

Could you please help me, i hope being clear.

Best Regards 

2 ACCEPTED SOLUTIONS
Anonymous
Not applicable

try this

 

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcvTVNTAwV9JRUorVQeIZG+gbWOgbGRgZoIob6htYIoSdQ3QNjM1gmuE8ZM2xAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [CA_Num = _t, F_ABOLIGNE.DateDebut = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"CA_Num", type text}, {"F_ABOLIGNE.DateDebut", type date}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Status", each   try if [F_ABOLIGNE.DateDebut]= null then Project_PM_Alloc{[PROJECT REF=[CA_Num]]}[Status] else if [F_ABOLIGNE.DateDebut]> Date.From( DateTime.LocalNow()) then "On Going" else "Delivered" otherwise "N/A")
in
    #"Added Custom"

 

 

 

image.png

 

@Ope_AF 

edited to match your label

 

View solution in original post

I tried this but it doesn't works actually the real name is :

T1 : Project_PM_Alloc

T2: F_ABOENTETE

date : F_ABOLIGNE.DateDebut

project in T1 : PROJECT REF

project in T2 : CA_Num

Could you update the formula with this name ?
Thank you very much for your answer
Best Regards

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

try this

 

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcvTVNTAwV9JRUorVQeIZG+gbWOgbGRgZoIob6htYIoSdQ3QNjM1gmuE8ZM2xAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [CA_Num = _t, F_ABOLIGNE.DateDebut = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"CA_Num", type text}, {"F_ABOLIGNE.DateDebut", type date}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Status", each   try if [F_ABOLIGNE.DateDebut]= null then Project_PM_Alloc{[PROJECT REF=[CA_Num]]}[Status] else if [F_ABOLIGNE.DateDebut]> Date.From( DateTime.LocalNow()) then "On Going" else "Delivered" otherwise "N/A")
in
    #"Added Custom"

 

 

 

image.png

 

@Ope_AF 

edited to match your label

 

I tried this but it doesn't works actually the real name is :

T1 : Project_PM_Alloc

T2: F_ABOENTETE

date : F_ABOLIGNE.DateDebut

project in T1 : PROJECT REF

project in T2 : CA_Num

Could you update the formula with this name ?
Thank you very much for your answer
Best Regards

Anonymous
Not applicable

or, using the null coalescing operator, instead try ... otherwise

 

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcvTVNTAwV9JRUorVQeIZG+gbWOgbGRgZoIob6htYIoSdQ3QNjM1gmuE8ZM2xAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Project = _t, Date = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Project", type text}, {"Date", type date}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Status", each  if [Date]= null then (T1{[Project=[Project]]}?[Status]?)??"N/A" else if [Date]> Date.From( DateTime.LocalNow()) then "On Going" else "Delivered")
in
    #"Added Custom"

 

 

 

Greg_Deckler
Community Champion
Community Champion

@Ope_AF - You should be able to do something like this:

Column = 
  VAR __Status = LOOKUPVALUE('Table1'[Status],'Table1'[Project],'Table2'[Project])
RETURN
  SWITCH(TRUE(),
    ISBLANK([Date]) && ISBLANK(__Status),"N/A",
    ISBLANK([Date]),__Status,
    <additional logic goes here>
  )

Not sure I fully understand your "outdated" logic. 



Follow on LinkedIn
@ 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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

I'm not really confortable with DAX Language so i don't understand well your solution but thanks,
I mean the day is in the past by "outdated"
Best regards

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.