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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anhcuong_ACP
Regular Visitor

I need to use DAX function to get data like two columns: Fruit, fresh, frozen, juice

z5714989263721_885c426f44326270025d3fce961a8f0a.jpg

1 ACCEPTED SOLUTION
qqqqqwwwweeerrr
Super User
Super User

Hi @Anhcuong_ACP 

 

I am not 100% clear about your question. Id you already have sat fruit list then the solution i am suggesting it will work, else need to check. 

 

here is my approach to solve problem. I am assuming you have list of fruits for extracting from long sentence. 

 

qqqqqwwwweeerrr_0-1723213369988.png

Here is the custom column: 

NewColumn =
VAR Sentence = 'Table'[Sentence]
VAR Word1 = IF(CONTAINSSTRING(Sentence, "rffrfvr"), "rffrfvr", BLANK())
VAR Word2 = IF(CONTAINSSTRING(Sentence, "frefed"), "frefed", BLANK())
VAR Word3 = IF(CONTAINSSTRING(Sentence, "frefer"), "frefer", BLANK())
RETURN
CONCATENATE(CONCATENATE(Word1, IF(Word1 <> BLANK() && Word2 <> BLANK(), ", ", "")), CONCATENATE(Word2, IF((Word1 <> BLANK() || Word2 <> BLANK()) && Word3 <> BLANK(), ", ", "") & Word3))
you can create two column here with differnet word list.
 

Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Check for more intersing solution here: www.youtube.com/@Howtosolveprobem

Regards

View solution in original post

6 REPLIES 6
Anhcuong_ACP
Regular Visitor

z5717878018316_15081f17740a33a19fbb6dac226f872f.jpg

This is the problem I am having

NewColumn =
VAR Sentence = 'Table'[Sentence]
VAR WordList =
SELECTCOLUMNS(
UNION(
ROW("Word", "rffrfvr"),
ROW("Word", "frefed"),
ROW("Word", "frefer")
-- Add more words here as needed
),
"Word", [Word]
)
VAR FoundWords =
FILTER(
WordList,
CONTAINSSTRING(Sentence, [Word])
)
RETURN
CONCATENATEX(FoundWords, [Word], ", ")
try this one hope this shold work if you have more number of word to check

Anhcuong_ACP
Regular Visitor

I see what you mean. I'm having an error problem when adding word4, can you help me?

CONCATENATE(CONCATENATE(Word1, IF(Word1 <> BLANK() && Word2 <> BLANK(), ", ", "")), CONCATENATE(Word2, IF((Word1 <> BLANK() || Word2 <> BLANK()) && Word3 <> BLANK(), ", ", "") & Word3 && Word4))))
qqqqqwwwweeerrr
Super User
Super User

Hi @Anhcuong_ACP 

 

I am not 100% clear about your question. Id you already have sat fruit list then the solution i am suggesting it will work, else need to check. 

 

here is my approach to solve problem. I am assuming you have list of fruits for extracting from long sentence. 

 

qqqqqwwwweeerrr_0-1723213369988.png

Here is the custom column: 

NewColumn =
VAR Sentence = 'Table'[Sentence]
VAR Word1 = IF(CONTAINSSTRING(Sentence, "rffrfvr"), "rffrfvr", BLANK())
VAR Word2 = IF(CONTAINSSTRING(Sentence, "frefed"), "frefed", BLANK())
VAR Word3 = IF(CONTAINSSTRING(Sentence, "frefer"), "frefer", BLANK())
RETURN
CONCATENATE(CONCATENATE(Word1, IF(Word1 <> BLANK() && Word2 <> BLANK(), ", ", "")), CONCATENATE(Word2, IF((Word1 <> BLANK() || Word2 <> BLANK()) && Word3 <> BLANK(), ", ", "") & Word3))
you can create two column here with differnet word list.
 

Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Check for more intersing solution here: www.youtube.com/@Howtosolveprobem

Regards

Thanks. exactly what I wanted, but I need to increase Word 4, Word 5,.........how should I use the next formula to append to the formula you made

Hi @Anhcuong_ACP 

 

It would be same you jest need to aad correct words. That y i have only send one formula since change the words and resuse to create new.

 

Regards

 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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