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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
Jsonify
Frequent Visitor

Need help implementing WHERE clause in Power Query

In my SELECT statement, I am having trouble implementing the WHERE clause since it is using the LOWER command. I'm also struggling to get the ('(Invalid)', ('Not Specified')') parts of the statement.

 

SELECT DISTINCT
    T_TESTCASE.ORIGIN_ID AS "Test Case ID",
    T_TESTCASE.NAME AS "Test Case Name",
    T_TESTCASE.TESTCASEFOLDER_NAME1 AS "Test Case Top folder name",
    T_TESTCASE.FULLPATH AS "Test Case Fullpath",
    T_TESTEXECSTATUS.NAME AS "Test Execution Status",
    T_USER.FULLNAME AS "Test Case Designer",
    T_HASREQUIREMENT.NAME AS "Has Requirement",
    T_PROJECT.DOMAIN_NAME AS "Domain Name",
    T_PROJECT.NAME AS "Project Name"
FROM T_TESTCASE
    INNER JOIN T_TESTEXECSTATUS ON T_TESTCASE.T_TESTEXECSTATUS_ID = T_TESTEXECSTATUS.T_TESTEXECSTATUS_ID
    INNER JOIN T_USER ON T_TESTCASE.T_DESIGNER_ID = T_USER.T_USER_ID
    INNER JOIN T_HASREQUIREMENT ON T_tESTCASE.T_HASREQUIREMENT_ID = T_HASREQUIREMENT.T_HASREQUIREMENT_ID
    INNER JOIN T_PROJECT ON T_TESTCASE.T_PROJECT_ID = T_PROJECT.T_PROJECT_ID
WHERE
    NOT (T_TESTCASE.TESTCASEFOLDER_NAME1 IN ('(Invalid)', '(Not Specified)')
       OR LOWER(T_TESTCASE.TESTCASEFOLDER_NAME1) LIKE '%archive%'
       OR LOWER(T_TESTCASE.TESTCASEFOLDER_NAME1) LIKE '%recycle%bin%'
       OR LOWER(T_TESTCASE.TESTCASEFOLDER_NAME1) LIKE '%temp%'
       OR LOWER(T_TESTCASE.TESTCASEFOLDER_NAME1) LIKE '%delete%')
AND T_TESTCASE.DELETED_DATETIME IS NULL
AND T_PROJECT.DELETED_DATETIME IS NULL
AND T_PROJECT.DOMAIN_NAME NOT IN ('(Invalid)', '(Not Specified)')

 

Any advice would be amazing. Thanks.

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Jsonify , Tables should be joined

 

you need to have two filter clauses

 

filter(T_TESTCASE,
NOT (T_TESTCASE[TESTCASEFOLDER_NAME1] IN ('(Invalid)', '(Not Specified)')
|| SEARCH("archive",T_TESTCASE.TESTCASEFOLDER_NAME1,1,0) >0
|| SEARCH("recycle%bin",T_TESTCASE.TESTCASEFOLDER_NAME1,1,0) >0
|| SEARCH("temp"T_TESTCASE.TESTCASEFOLDER_NAME1,1,0) >0

 

https://www.sqlbi.com/articles/the-importance-of-star-schemas-in-power-bi/

https://www.sqlshack.com/implementing-star-schemas-in-power-bi-desktop/
|| SEARCH("delete"T_TESTCASE.TESTCASEFOLDER_NAME1,1,0) >0
&& isblank(T_TESTCASE[DELETED_DATETIME]))


, filter(T_PROJECT, isblank(T_PROJECT[DELETED_DATETIME]) && NOT(T_PROJECT.DOMAIN_NAME IN {"(Invalid)", "(Not Specified)"}))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@Jsonify , Tables should be joined

 

you need to have two filter clauses

 

filter(T_TESTCASE,
NOT (T_TESTCASE[TESTCASEFOLDER_NAME1] IN ('(Invalid)', '(Not Specified)')
|| SEARCH("archive",T_TESTCASE.TESTCASEFOLDER_NAME1,1,0) >0
|| SEARCH("recycle%bin",T_TESTCASE.TESTCASEFOLDER_NAME1,1,0) >0
|| SEARCH("temp"T_TESTCASE.TESTCASEFOLDER_NAME1,1,0) >0

 

https://www.sqlbi.com/articles/the-importance-of-star-schemas-in-power-bi/

https://www.sqlshack.com/implementing-star-schemas-in-power-bi-desktop/
|| SEARCH("delete"T_TESTCASE.TESTCASEFOLDER_NAME1,1,0) >0
&& isblank(T_TESTCASE[DELETED_DATETIME]))


, filter(T_PROJECT, isblank(T_PROJECT[DELETED_DATETIME]) && NOT(T_PROJECT.DOMAIN_NAME IN {"(Invalid)", "(Not Specified)"}))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
lbendlin
Super User
Super User

"Lower" is the least of your problems. Power Query does not have the concept of wildcards.

 

Lower:  https://docs.microsoft.com/en-us/powerquery-m/text-lower

search: https://docs.microsoft.com/en-us/powerquery-m/text-contains

NOT IN statement:  use lists:  {"(Invalid)", "(Not Specified)"}

 

Fun fact - you can't use the lists for the search.  Need to use or and and.

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.