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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Slicer is not limiting a measure that checks for specific keywords in descriptions

I am trying to use a measure to score specific data based on how many keywords appear in the description, the keywords considered should be limited by a slicer. For example, if in the slicer the word brown and large are selected, an item with both words in the description will be scored 2, one with only one of the words will be scored 1 and the rest will be scored 0. This data is then used to create a bar chart.

I am using the following function: 

KeywordScore = CALCULATE(COUNT(KeyWords[KeywordsC]),CONTAINSSTRING(SELECTEDVALUE('DIM-Description'[Description]),KeyWords[KeywordsC]))

KeywordsC contains the keywords
Desciption contains the descriptions

The slicer is filtering on KeywordsC
 
Right now the measure works, but not in accordance with the slicer, the results are always as if the entire column is selected.

I hope you can assist me with correcting this fault in the report.

Please find sample data and BI File through this link.
https://drive.google.com/drive/folders/1C-WRj8VeInM4zst14o09tXnioPQzR2Rn?usp=sharing
1 ACCEPTED SOLUTION
v-yangliu-msft
Community Support
Community Support

Hi  @Anonymous ,

Here are the steps you can follow:

1. Create measure.

Measure =
var _table=ADDCOLUMNS(ALLSELECTED(KeyWords[KeywordsC]),"1",MAX('Facts-Beer'[Description]))
var _table1=ADDCOLUMNS(_table,"Flag",IF(CONTAINSSTRING([1],[KeywordsC]),1,0))
return
SUMX(_table1,[Flag])

2. Result:

vyangliumsft_0-1640331300704.png

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

View solution in original post

4 REPLIES 4
v-yangliu-msft
Community Support
Community Support

Hi  @Anonymous ,

Here is the link of the function, I hope it helps you:

 

ADDCOLUMNS

ALLSELECTED

CONTAINSSTRING

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

v-yangliu-msft
Community Support
Community Support

Hi  @Anonymous ,

Here are the steps you can follow:

1. Create measure.

Measure =
var _table=ADDCOLUMNS(ALLSELECTED(KeyWords[KeywordsC]),"1",MAX('Facts-Beer'[Description]))
var _table1=ADDCOLUMNS(_table,"Flag",IF(CONTAINSSTRING([1],[KeywordsC]),1,0))
return
SUMX(_table1,[Flag])

2. Result:

vyangliumsft_0-1640331300704.png

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

Anonymous
Not applicable

Hello Liu Yang,

 

If you have the time and are willing, could you help explain what the function does. Would increase my odds of coming up with a solution myself in the future.

 

Kind regards,

 

Romar

edhans
Super User
Super User

You will likely need to supply some sample data and share a sample PIBX.

 

How to get good help fast. Help us help you.

How To Ask A Technical Question If you Really Want An Answer

How to Get Your Question Answered Quickly - Give us a good and concise explanation
How to provide sample data in the Power BI Forum - Provide data in a table format per the link, or share an Excel/CSV file via OneDrive, Dropbox, etc.. Provide expected output using a screenshot of Excel or other image. Do not provide a screenshot of the source data. I cannot paste an image into Power BI tables.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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