I created a derived column in ADF using dynamic content as
iif(instr({userID},'_') > 0,toInteger(split({userID},'_')[2]),0) but I am unable to set it to default null instead of 0.
Above I am splitting all the digits after '_' and setting them as my output. But if there is no underscore then it should return a null.
Example 1:
Input 2jifh-ndifh3-idhf37-2323sd_445589
Output 445589
Example 2:
Input mkla4-5gj79a-df32ws-389shj-ks78ol
Output Null
--Update
Adding the answer by #MarkKromerMSFT for reference. Thanks Mark!
toInteger(null()) will work.
If you go through the official MS doc here for iif
Based on a condition applies one value or the other. If other is
unspecified it is considered NULL. Both the values must be
compatible(numeric, string...).
So you can try just,
iif(instr({userID},'_') > 0,toInteger(split({userID},'_')[2]))
Related
Problem: I can't figure out how to assert an captured value (Store Attribute) to the expected value.
What I'm trying to do: I'm still learning Selenium IDE. I figured out how to use Store Attribute to capture an Elements Style attribute and can Echo the variable to make sure I did indeed capture it. Now I want to compare (verify or assert) the value in the captured variable is equal to the expected value.
What I have tried: I've tried Assert Text, Assert Value, and have targetted the element attribute directly in the same way I captured it, then using the Value field for the expected value (like you would do asserting an "invalid" message. That seems to fail though. I've targeted the variable ${highligh} in the same way and it failed as well. So I'm not sure exactly how to verify/assert an attribute value.
In the images below, I've also tried Assert Text on the first and Assert Value on the second with Targets and Values remaining the same I just didn't capture the images.
After looking further for an answer here (StackOverflow) and elsewhere, just using the assert command as follows worked for me:
assert | <variable> (w/o ${}) | <expected-value>
I have an if condition in an ADF activity like below:
#if(
contains(activity('LookupWmkLastUpdateConfig').output,'firstRow')
,greater(
activity('LookupLastUpdateSrc').output.lastModified
,activity('LookupWmkLastUpdateConfig').output.firstRow.NewValueWatermark)
),
false)
The if condition looks as the last update date in src vs my database. Want I want to include is an additional block of code that evaluates an outside parameter called TypeLoad.
The current set-up only allows for full loads, I want to be able to include delta loads.
Does anyone know how to include such a piece of logic to the existing if code?
equals(pipeline().parameters.FwkItem['TypeLoad'],1)
The above condition would for example evaluate the full or delta load.
All help is very welcome.
Thanks!
I tried to repro this in my environment. I gave the same expression
#if(
contains(activity('LookupWmkLastUpdateConfig').output,'firstRow')
,greater(
activity('LookupLastUpdateSrc').output.lastModified
,activity('LookupWmkLastUpdateConfig').output.firstRow.NewValueWatermark)
),
false)
Same error function 'if' does not accept 2 arguments is occurred.
When the expression is looked into the reason for error, there were two closing parentheses near ,activity('LookupWmkLastUpdateConfig').output.firstRow.NewValueWatermark) ) .
Same is highlighted in the above image.
one parenthesis is removed and gave the expression as in below image.
#and(equals(pipeline().parameters.fwkitem,1),if(contains(activity('LookupWmkLastUpdateConfig').output,'firstRow'),greater(
activity('LookupLastUpdateSrc').output.lastModified
,activity('LookupWmkLastUpdateConfig').output.firstRow.NewValueWatermark)
,false))
Expression doesn't produce any error now.
I am trying to run spark query where I am creating curated table from a source table based upon values in parameter file.
properties_file.properties contains below key values:
substatus,allow,deny
SparkQuery is
//Code to load property file in parseConf
spark.sql(s"""insert into curated.table from source.table where
substatus='${parseConf.substatus}'""")
Above works with single value in substatus. But Can someone help what shall i do if I need to use substatus in ${parseConf.substatus} for multiple values from param as below.
spark.sql(s"""insert into curated.table from source.table where substatus in '${parseConf.substatus}'""")
To resolve my problem, I updated my property file as:
substatus,'allow'-'deny'
Then in scala code, I implemented below logic:
val subStatus=(parseConf.substatus).replace('-',',')
spark.sql(s"""insert into curated.table from source.table where substatus in ('${subStatus}')""")
Above strategy helped in breaking the values in string to muliple parameters of IN clause.
Equalto operator expects 1 value to be passed other than directly reading the value from parameter file who make in pass a one string. You need to break the values and then use IN clause inplace of equalto(=).
Solved
Issue was due to error in child action as Thomas pointed out, not the way I was checking the variable value.
I've got a variable that's been initialized earlier in the LA. Later on I'm trying to check if the variable is empty using a condition.
Here's the output from the run history:
It looks like the variable is an empty string at this point, however the condition fails without any helpful information.
I've also tried null or wrapping the variable in the empty command and comparing to true/false. All gave the same failure.
You can use the length function in the expression. I've found it helpful to also coallesce the value to an empty string before checking length.
For me placing an empty string between double quotes in a condition action to recognize the empty string works well.
Be aware however that once you enter the empty string in the condition action and save your logic app, if you afterwards go back in the designer and reopen the condition action the empty string enclosed in double quotes ("") is not displayed anymore.
I have a parameter called Analyst group in this format :
[Dimension].[Analyst Group].&[Nl.Workplace.Foundation]
I want to pass this parameter to another report, to filter data. Its a multi value parameter. But the other report only accepts it in this format : [KanBan].[Analyst Group].&[Nl.Workplace.Foundation]
So im trying to isolate the "Nl.Workplace.Foundation", so i can do the following thing in the Go To Report parameter expression :="[KanBan].[Analyst Group].&["& --Isolated analyst group-- &"]" to create the desired format.
So what i need is to extract the part between .&[ and ]
But i really have no idea how to isolate that part of the string.
Found a solution! If i just use the Parameter.label instead of Parameter.value it automatically does what i want!
A different solution has been found, but I will still answer the initial question. It could help.
So what i need is to extract the part between .&[ and ]
You could use a regex.
This may not be the fastest way but it can handle most of the situations.
So let's assume you have a string containing:
[Dimension].[Analyst Group].&[Nl.Workplace.Foundation]
And you want to get the following string:
Nl.Workplace.Foundation
Just use the following expression:
=System.Text.RegularExpressions.Regex.Match("[Dimension].[Analyst Group].&[Nl.Workplace.Foundation]", "\.&\[(?<NWF>[^]]+)\]").Groups("NWF").Value
In the expression, replace the input string with your dynamic values, like for example:
=System.Text.RegularExpressions.Regex.Match(Fields!Dimension.Value & "." & Fields!AnalystGroup.Value, "\.&\[(?<NWF>[^]]+)\]").Groups("NWF").Value
I'm keeping the formula as simple as possible so that you can easily adapt it, with, say, handling the case where an input string will not have a match (with the above query it will return #Error).
You could do this by adding an IIF() or better, use a custom function that you can reuse in several places and will reduce the length of your expression.