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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

lookup value and search string

Hi all ... 

 

I have aged a decade trying to figure out a way around this 

 

My 'Key Search' formula works well for another report I built, but I can't figure out how to add an extra criteria to it: 

Key Search = var result = CONCATENATEX('Report Key',IF(SEARCH(FIRSTNONBLANK('Report Key'[SearchString],1),PROJEMPTRANS[CRSEXTCOMMENT],,1111)<> 1111,'Report Key'[Work Type],"")) return if(result <> blank(), result, "n/a")
 
I need the formula to search the column in my data table 'CRSEXTCOMMENT' and match the SearchString to the comment - THEN - I need it to look at the 'WRKCATEGORY' of that row, match it to the 'Category' column to return the correct 'Work Type' 
 
i.e - 
If the CRSEXTCOMMENT contains  'Project Managment' and the Wrk Category assigned is 'Consulting hours' than return 'Project Management' 
 
If the CRSEXTCOMMENT contains 'Project Managment' and the Wrk Category assigned is 'Management' than return 'Non chargeable Project Management' 
 
and so on... 
 
Reason for this is that I need to be able to report on chargeable and non chargeable project management time booked to a project - also people may write in more information than just the key string text so its a failsafe. 

 

ALemmy_0-1608249648046.png

If anyone could help me out or tell me if I am over egging it I would really appreciate it 🙂 
 
Be blessed 
 
Anne
1 ACCEPTED SOLUTION

Hi, @Anonymous 

 

It’s my pleasure to answer for you.

According to your description,I think you can create a measure to calculate the desired result.

Like this:

Measure =
IF (
    SEARCH (
        SELECTEDVALUE ( 'Report Key'[SearchString] ),
        PROJEMPTRANS[CRSEXTCOMMENT],
        ,
        0
    ) > 0
        && SELECTEDVALUE ( 'Report Key'[Work Type] ) = "Consulting hours",
    SELECTEDVALUE ( 'Report Key'[SearchString] ),
    IF (
        SEARCH (
            SELECTEDVALUE ( 'Report Key'[SearchString] ),
            PROJEMPTRANS[CRSEXTCOMMENT],
            ,
            0
        ) > 0
            && SELECTEDVALUE ( 'Report Key'[Work Type] ) = "Management",
        "Non chargeable " & SELECTEDVALUE ( 'Report Key'[SearchString] ),
        "n/a"
    )
)

3.png

Here is my sample .pbix file.Hope it helps.

If it doesn’t solve your problem, please feel free to ask me.

 

Best Regards

Janey Guo

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
AllisonKennedy
Super User
Super User

@Anonymous  It looks like you already have the results column in the screenshot of your table? What is it that you are missing or what's not working? Also see if the CONTAINSSTRING function might help here?


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Anonymous
Not applicable

Im half way there, problem is as the key word search is not unique I get this:

 

ALemmy_0-1608285334421.png

 

I need it to say either - 'non chargeable project management' or 'project management' not both

 

As the 'wrk category' for this line is 'Consulting hours' it should return 'Project Management' as those words in that category relate to work type 'project management' in my report key table. 

 

😞I'm trying to see what I can do with 'containsstring' but im just getting errored out 😞 

 

@Anonymous  The conditions need to be unique. Why do you know that it's Project Management for that row? You just need to add that as an additional condition. You can use 

&&

to combine multiple conditions into one statement/filter expression.


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Hi, @Anonymous 

 

It’s my pleasure to answer for you.

According to your description,I think you can create a measure to calculate the desired result.

Like this:

Measure =
IF (
    SEARCH (
        SELECTEDVALUE ( 'Report Key'[SearchString] ),
        PROJEMPTRANS[CRSEXTCOMMENT],
        ,
        0
    ) > 0
        && SELECTEDVALUE ( 'Report Key'[Work Type] ) = "Consulting hours",
    SELECTEDVALUE ( 'Report Key'[SearchString] ),
    IF (
        SEARCH (
            SELECTEDVALUE ( 'Report Key'[SearchString] ),
            PROJEMPTRANS[CRSEXTCOMMENT],
            ,
            0
        ) > 0
            && SELECTEDVALUE ( 'Report Key'[Work Type] ) = "Management",
        "Non chargeable " & SELECTEDVALUE ( 'Report Key'[SearchString] ),
        "n/a"
    )
)

3.png

Here is my sample .pbix file.Hope it helps.

If it doesn’t solve your problem, please feel free to ask me.

 

Best Regards

Janey Guo

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.

Top Solution Authors