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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
SarathB2
Frequent Visitor

Need help with Dax

Hello Experts,

Good Day!
I am stuck with finding  and extract the values from  a column which "StartsWith" any of the value from another column which are true.

Example - 

I have two tables with one column each

Table 1

 

Type
Cat
Dog
Bag
Ball
Hello

 

Table 2

Object
Dog eye
Cat Food
School Bag
BaseBall

!HelloWorld

 

I achived output to check whether  Object started with Type or not like below  result with below DAX queries

Output

ObjectFlag
Dog eyeTRUE
Cat FoodTRUE
School BagFALSE
BaseBallFALSE
!HelloWorldFALSE
 
* Column:
Flag =
VAR SO = Table2[Object]
VAR Tab = FILTER(Table1, CONTAINSSTRING(LEFT(SO,LEN(Table1[Type])),Table1[Type]))
RETURN
IF( COUNTROWS(Tab) > 0, TRUE(),FALSE())

 

(or)

Flag =
IF (
SUMX (
Table1,
FIND (
UPPER ( Table1[Type] ),
LEFT ( UPPER ( Table2[Object] ), LEN ( Table1[Type] ) ),
,
0
)
) > 0,
TRUE (),
FALSE ()
)


Now I am seeking for the result like below , if Object column started with Type then i want that "Type" name in the column means where it is True and remaing blank().

 

Result,

ObjectFlagType
Dog eyeTRUEDog
Cat FoodTRUECat
School BagFALSE 
BaseBallFALSE 
!HelloWorldFALSE 


Thanks in Advance...

Regards,
Sarath.

 @gvrajesh  , @Icey , @AlexisOlson , @v-easonf-msft ,@amitchandak ,@AllisonKennedy , @parry2k 

2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@SarathB2 , Try like

 

Flag =
VAR SO = Table2[Object]
VAR _Tab = maxx(FILTER(Table1, CONTAINSSTRING(LEFT(SO,LEN(Table1[Type])),Table1[Type])), Table[Type])
RETURN
_tab

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

Fowmy
Super User
Super User

@SarathB2 

Try the following column:

Item = 
VAR SO = Table2[Object]
VAR Tab = VALUES('Table1'[Type] )
RETURN
IF(
    Table2[Flag],
    MAXX(
        FILTER(
            Table1,
            CONTAINSSTRING( SO , Table1[Type] )
        ),
        Table1[Type]
    )
)
Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

5 REPLIES 5
Fowmy
Super User
Super User

@SarathB2 

Try the following column:

Item = 
VAR SO = Table2[Object]
VAR Tab = VALUES('Table1'[Type] )
RETURN
IF(
    Table2[Flag],
    MAXX(
        FILTER(
            Table1,
            CONTAINSSTRING( SO , Table1[Type] )
        ),
        Table1[Type]
    )
)
Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

amitchandak
Super User
Super User

@SarathB2 , Try like

 

Flag =
VAR SO = Table2[Object]
VAR _Tab = maxx(FILTER(Table1, CONTAINSSTRING(LEFT(SO,LEN(Table1[Type])),Table1[Type])), Table[Type])
RETURN
_tab

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hello @amitchandak , @Fowmy 

In my case , one of Type is "ANG" 
when i try to search that one "ANGULAR" also consedering in Object as pass as it is staring with ANG.
how to avoid this .....
I tried to give a space after ANG like "ANG " but when its come to Desktop its not taking the space .

Please assist,

Thanks in advance.

@SarathB2 

I modified my code, now you do not need the Flag column.

Item = 
VAR SO = Table2[Object]
VAR Tab = VALUES('Table1'[Type] )
VAR Obj = 
    IF( SEARCH(" ", Table2[Object],1,BLANK()) = BLANK(),
        Table2[Object],
        TRIM(LEFT( Table2[Object] , SEARCH(" ", Table2[Object],1,BLANK()) ))
    )
VAR Result = 
MAXX(  FILTER(ALL('Table1'[TYPE]), Table1[Type] = OBJ) , Table1[Type] )

RETURN
   Result
Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Hello @amitchandak ,

 

Thanks a lot, it's working perfectly. Greaful for Quick response.

Regards,
Sarath.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.