Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Grab multiple values from slicer and put it in a search measure to filter report table
I have Two Tables - No Relationship
'Azure_LastLoginDateReport' - Table, contains Displayname, Email etc of users
'EmailTypeSearch' - Table contains a column [EmailSuffix] which holds search strings such as: @BBC.com, @CNN.com, @Sky.com, @abc.com
I use the slicer 'EmailTypeSearch' [EmailSuffix] to select single values and filter the table report accordingly.
I use a measure "Exists" that looks at the selected Value and then filters the table report based on selected value. - See
Exists = SEARCH(
SELECTEDVALUE('EmailTypeSearch'[EmailSuffix]),
SELECTEDVALUE('Azure_LastLoginDateReport'[Email]),
,-1)
The issue is: When trying to select multiple values in the slicer to filter the table below, it does not work.
I have seen the use of ALLSELECTED and IN and also the use of a variable, similar to the image below, but I do not know how to apply it to a Search function., as detailed above
I will be extremely grateful, if you could assist in getting me pass this stage in my development.
Solved! Go to Solution.
SELECTEDVALUE only works when there is only 1 value. To use multiple strings you could iterate over each one and check for a match. I don't know how well this will do performance-wise but you could try
Exists =
MAXX (
VALUES ( 'EmailTypeSearch'[EmailSuffix] ),
SEARCH (
'EmailTypeSearch'[EmailSuffix],
SELECTEDVALUE ( 'Azure_LastLoginDateReport'[Email] ),
,
-1
)
)
SELECTEDVALUE only works when there is only 1 value. To use multiple strings you could iterate over each one and check for a match. I don't know how well this will do performance-wise but you could try
Exists =
MAXX (
VALUES ( 'EmailTypeSearch'[EmailSuffix] ),
SEARCH (
'EmailTypeSearch'[EmailSuffix],
SELECTEDVALUE ( 'Azure_LastLoginDateReport'[Email] ),
,
-1
)
)
Hi @johnt75 - Thank you so much. That worked as expected. I am only dealing with circa 10k records, therefore it should be fine performance wise. Many thanks.
For ALL - I am also be interetsed how this script can be adapted to use a variable, but only if feasible and possible as I can see cases where this may be needed. for example where a search and sub-search is required
User | Count |
---|---|
76 | |
75 | |
46 | |
31 | |
27 |
User | Count |
---|---|
99 | |
91 | |
51 | |
48 | |
47 |