Forum Discussion
Search a Field Within A Query List
- 8 years ago
Hi bobbybamber,
Try this calculated column formula
=FIRSTNONBLANK(FILTER(VALUES(Country[Country]),SEARCH(Country[Country],[Text],1,0)),1)
Thanks MarcelBeug
It's really powerful feature. I just noticed that there is no comma between [Splitted])m and ([Column1], so [Splitted])([Column1]) are squashed together. How is this even possible to have two separate objects as a single parameter for Splitter.SplitTextByEachDelimiter? Is this pertains only to the splitter functions or it's normal to see across other M functions?
Thank you
Natasha: In my previous post I explained which parts can be distinguished in my formula's.
Maybe it will be clearer if I separate the 2 functions of the first split:
So step MySplitterOnCountryFunction adds a column with a function in each row thet can be used to split a string on the delimiters in CountryList. So the parameter here is CountryList.
Step SplittedOnCountry uses those functions to perform the actual split of the strings in Column1. So the parameter here is Column1.
In my original solution this is combined in 1 step, so it appears like: functionx(parameter1)(parameter2)
If you split this in 2 steps it looks like:
functiony = functionx(parmeter1)
FinalResult = functiony(parameter2)
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45Wck7MLUjMTM9TMFTQVQgGMvOAtFNRYl5KZl66UqwOUEWAux+KrEtmUWpyiUJQanFBfl5xKkQRzBgjkEr31KLcxLxKDJOQ7Qr1Rpf2yk8tyIQYB7Eqs1jB3xvMD8+ohBmKkFeKjQUA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}}),
MySplitterOnCountryFunction = Table.AddColumn(#"Changed Type","MySplitterOnCountryFunction", each Splitter.SplitTextByAnyDelimiter(CountryList)),
SplittedOnCountry = Table.AddColumn(MySplitterOnCountryFunction,"Splitted", each [MySplitterOnCountryFunction]([Column1])),
RemovedBlankListItems = Table.TransformColumns(SplittedOnCountry,{{"Splitted", each List.Select(_, each _ <> "")}}),
AddedCountry = Table.AddColumn(RemovedBlankListItems, "Country", each Splitter.SplitTextByEachDelimiter([Splitted])([Column1])),
FirstNonBlankOrNull = Table.TransformColumns(AddedCountry,{{"Country", each List.First(List.Select(_, each _ <> ""),null), type text}}),
#"Removed Columns" = Table.RemoveColumns(FirstNonBlankOrNull,{"MySplitterOnCountryFunction","Splitted"})
in
#"Removed Columns"- Anonymous8 years agoNot applicable
Intersting! So, the splitter funcitionality is clear.
Does this mean that ([Column1]) is a part of the Table.AddColumn function, not splitter function, right?
SplittedOnCountry = Table.AddColumn(#"Changed Type","Splitted", each Splitter.SplitTextByAnyDelimiter(CountryList)([Column1]))- MarcelBeug8 years agoCommunity Champion
That depends on how you define "is part of". Actually, to me that is rather confusing.
I think the question should be: which part is parameter for which function?
The parameters for function Table.AddColumn are:
#"Changed Type"
"Splitted"
each Splitter.SplitTextByAnyDelimiter(CountryList)([Column1])
The parameter for function Splitter.SplitTextByAnyDelimiter is:
CountryList
The parameter for function Splitter.SplitTextByAnyDelimiter(CountryList) is:
Column1
So if I translate "is part of" to "is parameter of" then the answer is: no.
Column1 is not "part of" function Table.AddColumn, but
Column1 is "part of" function Splitter.SplitTextByAnyDelimiter(CountryList)
- Anonymous8 years agoNot applicable
Wow! That's an unexpected twist.... Column1 is a parameter of Splitter.SplitTextByAnyDelimiter(CountryList).
Sorry I am taking too much of your time with this but just one more question.
May I please know how exactly Column1 acts as splitter funciton parameter if splitter function is closed with right parentheses after CountryList . Splitter.SplitTextByAnyDelimiter(CountryList) ([Column1]) <--- right parentheses closes the splitter function...
This is the first time I see such behavior ....
Thank you very much for your time MarcelBeug
- soni278 years agoHelper I
Great Method, My List is have like
TR
TRQ
TRP
The Spliier Picks up TR only even my string has TR and TRQ and TRP; It splits only TR.
Text Examples
PT-TR-Test0
PT-TRQ-Test1
PTTTT-TRP-Test2
Query results
TR
TR
TR
TR
TR
Results rexpected as :
TR
TRQ
TRP
Please share your advise on this
- singhv28 years agoHelper I
Hi Soni,
See if the solution in the below link helps.