Forum Discussion
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
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 tablevar countWords = COUNTROWS(values('root'[single root])) --words ticked in slicervar filtwords =COUNTROWS(FILTER('root' --filter slicer table,CONTAINSSTRING(curr,[single root]) --check if current word found in row)) --count how many words matched the rowRETURNif(filtwords = countWords --if the number of words in row match words ticked,1 --return 1,0 --others)
2 Replies
- SamWiseOwl
Super User
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 tablevar countWords = COUNTROWS(values('root'[single root])) --words ticked in slicervar filtwords =COUNTROWS(FILTER('root' --filter slicer table,CONTAINSSTRING(curr,[single root]) --check if current word found in row)) --count how many words matched the rowRETURNif(filtwords = countWords --if the number of words in row match words ticked,1 --return 1,0 --others)- no123Regular Visitor
thanks, it works