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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

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
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.