1

I am having a problem creating a conditional column in Power bi that finds/looks up words that begin with specific letters and then remove it for the column as showing in this example below. Values to remove are words that begins with the letters; FCL,MON and WOD

Can anybody help me?

Thank you!

Dataset

3
  • 1
    The logic in your example is not clear. What are the specific letters you are removing? Commented May 6, 2020 at 18:17
  • 1
    FYI this can be done with one simple formula in a single cell if you have access to Excel O365. Though I don't know what purpose this is for it might be interesting for you as an option. Commented May 6, 2020 at 20:04
  • It could be done within Excel but i prefer power bi so it automatically applies all the query's only by updating the dataset ( Excel files) otherwise i will have to work in two seperated platforms but thnx for the tip ;) Commented May 11, 2020 at 7:47

2 Answers 2

1

If they're all the s same length then you can write it more compactly like this:

if List.Contains({"WOD", "FCL", "MON"}, Text.Start([Input],3)) then "" else [Input]

Otherwise, you need to write each separately,

if Text.StartsWith([Input], "WOD") or
   Text.StartsWith([Input], "FCL") or
   Text.StartsWith([Input], "MON")
then "" else [Input]
Sign up to request clarification or add additional context in comments.

Comments

0

You can use create a conditional column.

Here is a screenshot of the conditional column and the condition "begins with":

enter image description here

Here is the result:

enter image description here

Here is the M code, be carefull, when you are trying to create something with M you need to "repeat" him what you just did. For example I indicated that my file had headers in the step before the conditional column, and thus, M repeats this within the new step like this : #"Promoted Headers"

    #"Promoted Headers" = Table.PromoteHeaders(#"Changed Type", [PromoteAllScalars=true]),
    #"Added Conditional Column" = Table.AddColumn(#"Promoted Headers", "Custom", each if Text.StartsWith([Input], "FCL") then " " else if Text.StartsWith([Input], "MON") then " " else if Text.StartsWith([Input], "WOD") then " " else [Input])
in
    #"Added Conditional Column"

I hope this helps

4 Comments

It's very simple to solve thank you!! i was thinking in a very difficult way and using all kind of unnecessary filters hahah
Wooo...my answer has been removed as useful...I wonder if a question can have to answers....
Both answers were actually great but stackoverflow only marks 1 answer. I have used your answer to solve my problem so you are getting the green check mark sorry for the inconvenience.
No worries. I am new to stackoverflow, I did not know that only "one answer" could be provided.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.