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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
rkee10
Frequent Visitor

Grouping of Questions to Create Category

Is it possible to create a report from a list of questions wherein it will group the type of questions as categories?  For example, i have these questions:

 

- What is a guitar

- Guitar

- define guitar

- How to cook meat?

 

3 counts should be under GUITAR query or category and 1 count would be under Cooking.  I hope this is clear.  Let me know otherwise.  Thanks!

1 ACCEPTED SOLUTION

Hi @rkee10 

 

If my understanding is correct then here are the step, to achieve what you have you need to create two custom column

First column

NewColumn =
VAR Sentence = 'Table'[Sentence]
VAR WordList =
SELECTCOLUMNS(
UNION(
ROW("Word", "guitar"),
ROW("Word", "cook")
-- Add more words here as needed
),
"Word", [Word]
)
VAR FoundWords =
FILTER(
WordList,
CONTAINSSTRING(Sentence, [Word])
)
RETURN
CONCATENATEX(FoundWords, [Word], ", ")
 
Second column:
CountColumn =
CALCULATE(
    COUNTROWS('Table'),
    FILTER('Table', 'Table'[NewColumn] = EARLIER('Table'[NewColumn]))
)
 
Here is below output for the same
 
qqqqqwwwweeerrr_0-1723646903934.png

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

5 REPLIES 5
rkee10
Frequent Visitor

Yes, the output should give a category and its count. 

Hi @rkee10 

 

If my understanding is correct then here are the step, to achieve what you have you need to create two custom column

First column

NewColumn =
VAR Sentence = 'Table'[Sentence]
VAR WordList =
SELECTCOLUMNS(
UNION(
ROW("Word", "guitar"),
ROW("Word", "cook")
-- Add more words here as needed
),
"Word", [Word]
)
VAR FoundWords =
FILTER(
WordList,
CONTAINSSTRING(Sentence, [Word])
)
RETURN
CONCATENATEX(FoundWords, [Word], ", ")
 
Second column:
CountColumn =
CALCULATE(
    COUNTROWS('Table'),
    FILTER('Table', 'Table'[NewColumn] = EARLIER('Table'[NewColumn]))
)
 
Here is below output for the same
 
qqqqqwwwweeerrr_0-1723646903934.png

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 for this one, @qqqqqwwwweeerrr !  By the way, how can I put this count to guitar:

- How can I play an instrument (or 6 string instrument)?


I would like to count this under guitar.  So for the answer you provided, the guitar should be 4 if we include this new sentence.  Basically, I want to count words in one category who have the same meaning (synonym).  Let me know if this is clear.  Appreciate your effort on this one.

qqqqqwwwweeerrr
Super User
Super User

Hi @rkee10 

 

What is expected output say you want to create a category column, based on given key words?

Yup, based on given keywords.

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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

Top Solution Authors