Forum Discussion

no123's avatar
no123
Regular Visitor
2 years ago
Solved

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...
  • SamWiseOwl's avatar
    2 years ago

    Hi no123 

    Something like this?

     

    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
    )