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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
pbianalyst
New Member

Create A Custom Column with and IF Statement that references values in a separate table.

Good afternoon, 

I have a table with 25 columns to identify different diagnosis codes. I would like to create a custom column that flags whether any of the diagnosis codes (180) in another table are in any of those 25 fields. Is there a DAX statement or any other way that can help me accomplish that task in Power BI?

Thanks in advance for your help!

1 ACCEPTED SOLUTION
jdbuchanan71
Super User
Super User

Trying to flag the Trigger Diags sounds like?  Something along these lines should work.  You would add this as a calculated column on the Claim table.

 

Trigger_Diagnosis = 
SWITCH (
    TRUE(),
    NOT ISBLANK ( LOOKUPVALUE ( Trigger_Diag[Diagnostic_Code], Trigger_Diag[Diagnostic_Code], Claim[Diagnostic_Code1] ) ), "Y",
    NOT ISBLANK ( LOOKUPVALUE ( Trigger_Diag[Diagnostic_Code], Trigger_Diag[Diagnostic_Code], Claim[Diagnostic_Code2] ) ), "Y",
    NOT ISBLANK ( LOOKUPVALUE ( Trigger_Diag[Diagnostic_Code], Trigger_Diag[Diagnostic_Code], Claim[Diagnostic_Code3] ) ), "Y",
    NOT ISBLANK ( LOOKUPVALUE ( Trigger_Diag[Diagnostic_Code], Trigger_Diag[Diagnostic_Code], Claim[Diagnostic_Code4] ) ), "Y",
    NOT ISBLANK ( LOOKUPVALUE ( Trigger_Diag[Diagnostic_Code], Trigger_Diag[Diagnostic_Code], Claim[Diagnostic_Code5] ) ), "Y",
    NOT ISBLANK ( LOOKUPVALUE ( Trigger_Diag[Diagnostic_Code], Trigger_Diag[Diagnostic_Code], Claim[Diagnostic_Code6] ) ), "Y",
    NOT ISBLANK ( LOOKUPVALUE ( Trigger_Diag[Diagnostic_Code], Trigger_Diag[Diagnostic_Code], Claim[Diagnostic_Code7] ) ), "Y",
    NOT ISBLANK ( LOOKUPVALUE ( Trigger_Diag[Diagnostic_Code], Trigger_Diag[Diagnostic_Code], Claim[Diagnostic_Code8] ) ), "Y",
    NOT ISBLANK ( LOOKUPVALUE ( Trigger_Diag[Diagnostic_Code], Trigger_Diag[Diagnostic_Code], Claim[Diagnostic_Code9] ) ), "Y",
    NOT ISBLANK ( LOOKUPVALUE ( Trigger_Diag[Diagnostic_Code], Trigger_Diag[Diagnostic_Code], Claim[Diagnostic_Code10] ) ), "Y",
    NOT ISBLANK ( LOOKUPVALUE ( Trigger_Diag[Diagnostic_Code], Trigger_Diag[Diagnostic_Code], Claim[Diagnostic_Code11] ) ), "Y",
    NOT ISBLANK ( LOOKUPVALUE ( Trigger_Diag[Diagnostic_Code], Trigger_Diag[Diagnostic_Code], Claim[Diagnostic_Code12] ) ), "Y",
    NOT ISBLANK ( LOOKUPVALUE ( Trigger_Diag[Diagnostic_Code], Trigger_Diag[Diagnostic_Code], Claim[Diagnostic_Code13] ) ), "Y",
    NOT ISBLANK ( LOOKUPVALUE ( Trigger_Diag[Diagnostic_Code], Trigger_Diag[Diagnostic_Code], Claim[Diagnostic_Code14] ) ), "Y",
    NOT ISBLANK ( LOOKUPVALUE ( Trigger_Diag[Diagnostic_Code], Trigger_Diag[Diagnostic_Code], Claim[Diagnostic_Code15] ) ), "Y",
    NOT ISBLANK ( LOOKUPVALUE ( Trigger_Diag[Diagnostic_Code], Trigger_Diag[Diagnostic_Code], Claim[Diagnostic_Code16] ) ), "Y",
    NOT ISBLANK ( LOOKUPVALUE ( Trigger_Diag[Diagnostic_Code], Trigger_Diag[Diagnostic_Code], Claim[Diagnostic_Code17] ) ), "Y",
    NOT ISBLANK ( LOOKUPVALUE ( Trigger_Diag[Diagnostic_Code], Trigger_Diag[Diagnostic_Code], Claim[Diagnostic_Code18] ) ), "Y",
    NOT ISBLANK ( LOOKUPVALUE ( Trigger_Diag[Diagnostic_Code], Trigger_Diag[Diagnostic_Code], Claim[Diagnostic_Code19] ) ), "Y",
    NOT ISBLANK ( LOOKUPVALUE ( Trigger_Diag[Diagnostic_Code], Trigger_Diag[Diagnostic_Code], Claim[Diagnostic_Code20] ) ), "Y",
    NOT ISBLANK ( LOOKUPVALUE ( Trigger_Diag[Diagnostic_Code], Trigger_Diag[Diagnostic_Code], Claim[Diagnostic_Code21] ) ), "Y",
    NOT ISBLANK ( LOOKUPVALUE ( Trigger_Diag[Diagnostic_Code], Trigger_Diag[Diagnostic_Code], Claim[Diagnostic_Code22] ) ), "Y",
    NOT ISBLANK ( LOOKUPVALUE ( Trigger_Diag[Diagnostic_Code], Trigger_Diag[Diagnostic_Code], Claim[Diagnostic_Code23] ) ), "Y",
    NOT ISBLANK ( LOOKUPVALUE ( Trigger_Diag[Diagnostic_Code], Trigger_Diag[Diagnostic_Code], Claim[Diagnostic_Code24] ) ), "Y"
    )

 

 

View solution in original post

3 REPLIES 3
v-stephen-msft
Community Support
Community Support

Hi @pbianalyst ,


Could you tell me if your problem has been solved?
If it is, kindly Accept it as the solution. More people will benefit from it.
Or you are still confused about it, please provide me with more details about your problem.


Best Regards,
Stephen Tao

jdbuchanan71
Super User
Super User

Trying to flag the Trigger Diags sounds like?  Something along these lines should work.  You would add this as a calculated column on the Claim table.

 

Trigger_Diagnosis = 
SWITCH (
    TRUE(),
    NOT ISBLANK ( LOOKUPVALUE ( Trigger_Diag[Diagnostic_Code], Trigger_Diag[Diagnostic_Code], Claim[Diagnostic_Code1] ) ), "Y",
    NOT ISBLANK ( LOOKUPVALUE ( Trigger_Diag[Diagnostic_Code], Trigger_Diag[Diagnostic_Code], Claim[Diagnostic_Code2] ) ), "Y",
    NOT ISBLANK ( LOOKUPVALUE ( Trigger_Diag[Diagnostic_Code], Trigger_Diag[Diagnostic_Code], Claim[Diagnostic_Code3] ) ), "Y",
    NOT ISBLANK ( LOOKUPVALUE ( Trigger_Diag[Diagnostic_Code], Trigger_Diag[Diagnostic_Code], Claim[Diagnostic_Code4] ) ), "Y",
    NOT ISBLANK ( LOOKUPVALUE ( Trigger_Diag[Diagnostic_Code], Trigger_Diag[Diagnostic_Code], Claim[Diagnostic_Code5] ) ), "Y",
    NOT ISBLANK ( LOOKUPVALUE ( Trigger_Diag[Diagnostic_Code], Trigger_Diag[Diagnostic_Code], Claim[Diagnostic_Code6] ) ), "Y",
    NOT ISBLANK ( LOOKUPVALUE ( Trigger_Diag[Diagnostic_Code], Trigger_Diag[Diagnostic_Code], Claim[Diagnostic_Code7] ) ), "Y",
    NOT ISBLANK ( LOOKUPVALUE ( Trigger_Diag[Diagnostic_Code], Trigger_Diag[Diagnostic_Code], Claim[Diagnostic_Code8] ) ), "Y",
    NOT ISBLANK ( LOOKUPVALUE ( Trigger_Diag[Diagnostic_Code], Trigger_Diag[Diagnostic_Code], Claim[Diagnostic_Code9] ) ), "Y",
    NOT ISBLANK ( LOOKUPVALUE ( Trigger_Diag[Diagnostic_Code], Trigger_Diag[Diagnostic_Code], Claim[Diagnostic_Code10] ) ), "Y",
    NOT ISBLANK ( LOOKUPVALUE ( Trigger_Diag[Diagnostic_Code], Trigger_Diag[Diagnostic_Code], Claim[Diagnostic_Code11] ) ), "Y",
    NOT ISBLANK ( LOOKUPVALUE ( Trigger_Diag[Diagnostic_Code], Trigger_Diag[Diagnostic_Code], Claim[Diagnostic_Code12] ) ), "Y",
    NOT ISBLANK ( LOOKUPVALUE ( Trigger_Diag[Diagnostic_Code], Trigger_Diag[Diagnostic_Code], Claim[Diagnostic_Code13] ) ), "Y",
    NOT ISBLANK ( LOOKUPVALUE ( Trigger_Diag[Diagnostic_Code], Trigger_Diag[Diagnostic_Code], Claim[Diagnostic_Code14] ) ), "Y",
    NOT ISBLANK ( LOOKUPVALUE ( Trigger_Diag[Diagnostic_Code], Trigger_Diag[Diagnostic_Code], Claim[Diagnostic_Code15] ) ), "Y",
    NOT ISBLANK ( LOOKUPVALUE ( Trigger_Diag[Diagnostic_Code], Trigger_Diag[Diagnostic_Code], Claim[Diagnostic_Code16] ) ), "Y",
    NOT ISBLANK ( LOOKUPVALUE ( Trigger_Diag[Diagnostic_Code], Trigger_Diag[Diagnostic_Code], Claim[Diagnostic_Code17] ) ), "Y",
    NOT ISBLANK ( LOOKUPVALUE ( Trigger_Diag[Diagnostic_Code], Trigger_Diag[Diagnostic_Code], Claim[Diagnostic_Code18] ) ), "Y",
    NOT ISBLANK ( LOOKUPVALUE ( Trigger_Diag[Diagnostic_Code], Trigger_Diag[Diagnostic_Code], Claim[Diagnostic_Code19] ) ), "Y",
    NOT ISBLANK ( LOOKUPVALUE ( Trigger_Diag[Diagnostic_Code], Trigger_Diag[Diagnostic_Code], Claim[Diagnostic_Code20] ) ), "Y",
    NOT ISBLANK ( LOOKUPVALUE ( Trigger_Diag[Diagnostic_Code], Trigger_Diag[Diagnostic_Code], Claim[Diagnostic_Code21] ) ), "Y",
    NOT ISBLANK ( LOOKUPVALUE ( Trigger_Diag[Diagnostic_Code], Trigger_Diag[Diagnostic_Code], Claim[Diagnostic_Code22] ) ), "Y",
    NOT ISBLANK ( LOOKUPVALUE ( Trigger_Diag[Diagnostic_Code], Trigger_Diag[Diagnostic_Code], Claim[Diagnostic_Code23] ) ), "Y",
    NOT ISBLANK ( LOOKUPVALUE ( Trigger_Diag[Diagnostic_Code], Trigger_Diag[Diagnostic_Code], Claim[Diagnostic_Code24] ) ), "Y"
    )

 

 

Thanks so much for your help and quick response. I will definetely try your solution.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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