Forum Discussion
Power Query - Replace Formula Operator with Parameter
- Anonymous3 years ago
Success, it works!
Here's the final code:
Expression.Evaluate(Text.From(List.Count( Text.ToList(Text.Select([line_item], #"01c: DV360 Line Item Delimiter - Display"))))&#"01a: DV360 LI Exact or Minimum"&Text.From(List.Count(#"01c: DV360 Line Item Fields - Display")-1),[_=_])Thanks so much for your help!
Hi wdx223_Daniel ,
Thanks for this. I've tried it on this simple version and it works. But now I'd like to try it with something a little more complex. Here's the original query step I want to use:
= Table.AddColumn(#"Campaign: Taxonomy Pattern", "Taxonomy Match - DV360 Campaign Name", each if List.Count(#"01a: DV360 Campaign Names Fields") = 0 then "No Taxonomy Pattern" else if List.Count( Text.ToList(Text.Select([campaign_name], #"01a: DV360 Campaign Name Delimiter"))) = List.Count(#"01a: DV360 Campaign Names Fields")-1 then "Correct Pattern" else "Pattern Error", Text.Type)This step looks at a field called Campaign_Name. It looks to identify the number of delimiters in the field. The delimiter comes from a parameter, called #"01a: DV360 Campaign Name Delimiter". It's then comparing this to a list of the delimiter fields. So if the Campaign_Name has the required number of delimiters, it will pass.
I want to be able to add my new parameter in place of the "=" so I can either have an exact or minimum number of delimiters matching.
I've taken your pattern and tried to use it on this, as follows:
= Table.AddColumn(#"Campaign: Taxonomy Pattern", "Taxonomy Match - DV360 Campaign Name", each if List.Count(#"01a: DV360 Campaign Names Fields") = 0 then "No Taxonomy Pattern" else if Expression.Evaluate("List.Count( Text.ToList(Text.Select([campaign_name], #"01a: DV360 Campaign Name Delimiter")))"&#"01a: DV360 Campaign Name Exact or Minimum"&"List.Count(#"01a: DV360 Campaign Names Fields")-1",[_=_]) then "Correct Pattern" else "Pattern Error", Text.Type)
But when I execute this, I get the following error: Expression.SyntaxError: Token ',' expected.
Any idea what I need to amend to correct this?
Thanks,
Mark
i did not get your point, and why your original code cannot get what you want?
- Anonymous3 years agoNot applicable
Hey,
I wanted to start with a simple example to see if I could take that and apply it to my more complex example. The simple version works but for some reason the more complex example doesn't. The error I'm getting says it's expecting ',' somewhere.
I'll breakdown the formula:
COUNT OF DELIMITERS: List.Count( Text.ToList(Text.Select([campaign_name], #"01a: DV360 Campaign Name Delimiter")))
REPLACE WITH PARAMETER: =
TARGET DELIMITERS: List.Count(#"01a: DV360 Campaign Names Fields")-1
Does that help?
- wdx223_Daniel3 years agoCommunity Champion
Text.From(List.Count( Text.ToList(Text.Select([campaign_name], #"01a: DV360 Campaign Name Delimiter"))))&ParameterValue&Text.From(List.Count(#"01a: DV360 Campaign Names Fields")-1)
is this ok?
- Anonymous3 years agoNot applicable
Hey,
It throws up errors with the following: