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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
deepu299
Advocate V
Advocate V

Lookup from Same Table and return true or false

Hi, I need help with DAX to return TRUE or FALSE from the following data set. For Acct# = 11, I want to check other rows with same Acct#, and if Persons are different, I want to compare Bag with Bag Combo (this is multiple bags separates with hyphen) and if exists then return TRUE, otherwise FALSE. 

  • Are there other entries in the data set that have this account number? (i.e., is there more than one bag on a given account?) 
  • If Yes, does the Bag of the Owner on the current row overlap with the Bag Combos carried by any of the people on the other rows for that account?


for Row 1 below, 11=11, Bob<>Sue, HR doesnt exist in Sue's Bag Combo so return FALSE

for Row 2, 11=11, Sue <> Bob, TN exists in Bob's Bag Combo (HR-TN) so return TRUE. 



RowAcct#BagPersonBag ComboNeed this
111HRBobHR-TNFALSE
211TNSueTNTRUE
312HRBobHR-TNFALSE
412TNBobHR-TNFALSE
513TNSueTNFALSE
613SalesHansSGENFALSE
714HRBobHR-TNFALSE
815HRBillHRFALSE
915TNSueTNFALSE
1016HRSallyHR-TNFALSE
1116TNSallyHR-TNFALSE
1216SalesHansSGENFALSE
1317HRBillHRTRUE
1417TNSallyHR-TNFALSE
2 ACCEPTED SOLUTIONS
Zubair_Muhammad
Community Champion
Community Champion

@deepu299 

 

This works with your sample data.

Assuming yourtablename is Table1

 

Calculated Column =
VAR myrow = [Row]
VAR Act = [Acct#]
VAR mybag = [Bag]
VAR myperson = [Person]
VAR SameAcc_DifRow =
    ADDCOLUMNS (
        FILTER ( Table1, [Acct#] = Act && [Row] <> myrow && [Person] <> myperson ),
        "BagFound", SEARCH ( mybag, [Bag Combo], 1, 0 )
    )
RETURN
    COUNTROWS ( FILTER ( SameAcc_DifRow, [BagFound] > 0 ) ) > 0

View solution in original post

Hi @deepu299 

 

Try this column to get Person with same bag.

See file attached as well

 

PersonWithSameBag =
VAR myrow = [Row]
VAR Act = [Acct#]
VAR mybag = [Bag]
VAR myperson = [Person]
VAR SameAcc_DifRow =
    ADDCOLUMNS (
        FILTER ( Table1, [Acct#] = Act && [Row] <> myrow && [Person] <> myperson ),
        "BagFound", SEARCH ( mybag, [Bag Combo], 1, 0 )
    )
RETURN
    CONCATENATEX ( FILTER ( SameAcc_DifRow, [BagFound] > 0 ), [Person], "," )

 

View solution in original post

3 REPLIES 3
Zubair_Muhammad
Community Champion
Community Champion

@deepu299 

 

This works with your sample data.

Assuming yourtablename is Table1

 

Calculated Column =
VAR myrow = [Row]
VAR Act = [Acct#]
VAR mybag = [Bag]
VAR myperson = [Person]
VAR SameAcc_DifRow =
    ADDCOLUMNS (
        FILTER ( Table1, [Acct#] = Act && [Row] <> myrow && [Person] <> myperson ),
        "BagFound", SEARCH ( mybag, [Bag Combo], 1, 0 )
    )
RETURN
    COUNTROWS ( FILTER ( SameAcc_DifRow, [BagFound] > 0 ) ) > 0

You are awesome. Thanks much @Zubair_Muhammad , the solution worked perfectly. Is it possible to show the person with the same bag when True?

Hi @deepu299 

 

Try this column to get Person with same bag.

See file attached as well

 

PersonWithSameBag =
VAR myrow = [Row]
VAR Act = [Acct#]
VAR mybag = [Bag]
VAR myperson = [Person]
VAR SameAcc_DifRow =
    ADDCOLUMNS (
        FILTER ( Table1, [Acct#] = Act && [Row] <> myrow && [Person] <> myperson ),
        "BagFound", SEARCH ( mybag, [Bag Combo], 1, 0 )
    )
RETURN
    CONCATENATEX ( FILTER ( SameAcc_DifRow, [BagFound] > 0 ), [Person], "," )

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors