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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
MB_PowerBI
New Member

Search a text in each row then create a new column

Hello,

 

I have the following sample data

IDDATA
1A
1A
2A
2B
3B

 

My need is to create a third column, which will check for each ID,
if there is at least and only A then list A
if there is at least and only B then list B
Else (there is at least one A and one B then A & B

IDDATAResult
1AA
1AA
2AA&B
2BA&B
3BB


Thanks for your help.

 

Regards,

1 ACCEPTED SOLUTION
FreemanZ
Super User
Super User

hi @MB_PowerBI 

 

try to add a column like this:

Result2 = 
VAR _id = [ID]
VAR _table=
CALCULATETABLE(
    VALUES(TableName[Data]),
    ALL(TableName),
    TableName[ID] = _id
)
RETURN
CONCATENATEX(
   _table,
    TableName[Data],
    "&"
)

 

it works like this:

FreemanZ_0-1671760818942.png

View solution in original post

3 REPLIES 3
CNENFRNL
Community Champion
Community Champion

CNENFRNL_0-1671825162085.png

 

For fun only, a showcase of powerful Excel worksheet formula,

CNENFRNL_1-1671825237325.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

FreemanZ
Super User
Super User

hi @MB_PowerBI 

 

try to add a column like this:

Result2 = 
VAR _id = [ID]
VAR _table=
CALCULATETABLE(
    VALUES(TableName[Data]),
    ALL(TableName),
    TableName[ID] = _id
)
RETURN
CONCATENATEX(
   _table,
    TableName[Data],
    "&"
)

 

it works like this:

FreemanZ_0-1671760818942.png

or something like this:

 

Result2 = 
VAR _table=
CALCULATETABLE(
    VALUES(TableName[Data]),
    ALLEXCEPT(TableName, TableName[ID])
)
RETURN
CONCATENATEX(
   _table,
    TableName[Data],
    "&"
)

 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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