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
no123
Regular Visitor

HELP WITH DAX CODE

Hi everyone
im new to PowerBI. Here is my request from clients. 
A Fact table contains keywords such as healthy toothpaste, christmas healthy toothpaste, yellow toothpaste,... etc. And each keyword has a same metrics such as orders, units throughout a year like this 

KEYWORDS                                                         Units        week
healthy toothpaste                                               4              1
toothpaste healthy male                                       5             2
christmas healthy toothpaste                               6              3
yellow toothpaste                                                 7              4
healthy toothpaste                                                10            2
And i have a DIM table that contains single root of keywords like this

single root
healthy
christmas
yellow 
toothpaste
By choosing multiple single roots, the table will illustrate the metrics of all keywords that contain all the selected root no matter of the position of root in keywords. 
For example: by choose healthy , toothpaste root, the results will be like this 
healthy toothpaste                                               4              1
toothpaste healthy male                                       5             2
christmas healthy toothpaste                               6              3
healthy toothpaste                                                10            2

Any solutions to do this in Power BI? Thanks all

1 ACCEPTED SOLUTION
SamWiseOwl
Super User
Super User

Hi @no123 

Something like this?

SamWiseOwl_0-1726732963700.png

 

I used a measure in the Filters on this visual section:

Contains word =
var curr = SELECTEDVALUE('Key'[Keywords])  --Current row in the table
var countWords = COUNTROWS(values('root'[single root])) --words ticked in slicer
var filtwords =
COUNTROWS(
    FILTER(
        'root' --filter slicer table
        ,CONTAINSSTRING(curr,[single root]) --check if current word found in row
    )) --count how many words matched the row
RETURN
if(
    filtwords = countWords --if the number of words in row match words ticked
    ,1 --return 1
    ,0 --others
)

If you are happy with this answer please mark as a solution for others to find !

Kudos are always appreciated! Check out our free Power BI video courses.

View solution in original post

2 REPLIES 2
SamWiseOwl
Super User
Super User

Hi @no123 

Something like this?

SamWiseOwl_0-1726732963700.png

 

I used a measure in the Filters on this visual section:

Contains word =
var curr = SELECTEDVALUE('Key'[Keywords])  --Current row in the table
var countWords = COUNTROWS(values('root'[single root])) --words ticked in slicer
var filtwords =
COUNTROWS(
    FILTER(
        'root' --filter slicer table
        ,CONTAINSSTRING(curr,[single root]) --check if current word found in row
    )) --count how many words matched the row
RETURN
if(
    filtwords = countWords --if the number of words in row match words ticked
    ,1 --return 1
    ,0 --others
)

If you are happy with this answer please mark as a solution for others to find !

Kudos are always appreciated! Check out our free Power BI video courses.

thanks, it works

 

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.