SRRS how to check if there is a certain value in dataset - visual-studio

I am trying to make a new ssrs report:
There is a details group that prints lines from datasource detailsDS.
I also want to make a textbox in the footer(or anywhere, doesn't matter) where if there was any(or more than one) line in detailDS with value that equals "Red" that textbox should be set invisible.
I already tried:
iif(first(Fields!Color.Value, "detailsDS") = "Red", True, false)
of course this doesn't work because it only searches for first record and textbox is out of scope of details.
Is it possible to solve this in report layer?
EDIT:
Seems like lookup function is not supported for ms dynamics.

As B.Seberie noted, you could use the lookup function.
=IIF(Lookup("Red", Fields!Color.Value, Fields!Color.Value, "detailsDS") = "Red", True, False)
You would want to use your static value of "Red" for the first argument. This is the value that will be searched for.
The second argument is for the field in the dataset that you want to check for the first argument's (Arg1) value.
The third argument (Arg3) is the field to return when it finds Arg1 in Arg2 - in this case you can just use the same color field. If the color is found, it will be TRUE otherwise it will be FALSE.

Related

Powerautomate Parsing JSON Array

I've seen the JSON array questions here and I'm still a little lost, so could use some extra help.
Here's the setup:
My Flow calls a sproc on my DB and that sproc returns this JSON:
{
"ResultSets": {
"Table1": [
{
"OrderID": 9518338,
"BasketID": 9518338,
"RefID": 65178176,
"SiteConfigID": 237
}
]
},
"OutputParameters": {}
}
Then I use a PARSE JSON action to get what looks like the same result, but now I'm told it's parsed and I can call variables.
Issue is when I try to call just, say, SiteConfigID, I get "The output you selected is inside a collection and needs to be looped over to be accessed. This action cannot be inside a foreach."
After some research, I know what's going on here. Table1 is an Array, and I need to tell PowerAutomate to just grab the first record of that array so it knows it's working with just a record instead of a full array. Fair enough. So I spin up a "Return Values to Virtual Power Agents" action just to see my output. I know I'm supposed to use a 'first' expression or a 'get [0] from array expression here, but I can't seem to make them work. Below are what I've tried and the errors I get:
Tried:
first(body('Parse-Sproc')?['Table1/SiteConfigID'])
Got: InvalidTemplate. Unable to process template language expressions in action 'Return_value(s)_to_Power_Virtual_Agents' inputs at line '0' and column '0': 'The template language function 'first' expects its parameter be an array or a string. The provided value is of type 'Null'. Please see https://aka.ms/logicexpressions#first for usage details.'.
Also Tried:
body('Parse-Sproc')?['Table1/SiteconfigID']
which just returns a null valued variable
Finally I tried
outputs('Parse-Sproc')?['Table1']?['value'][0]?['SiteConfigID']
Which STILL gives me a null-valued variable. It's the worst.
In that last expression, I also switched the variable type in the return to pva action to a string instead of a number, no dice.
Also, changed 'outputs' in that expression for 'body' .. also no dice
Here is a screenie of the setup:
To be clear: the end result i'm looking for is for the system to just return "SiteConfigID" as a string or an int so that I can pipe that into a virtual agent.
I believe this is what you need as an expression ...
body('Parse-Sproc')?['ResultSets']['Table1'][0]?['SiteConfigID']
You can see I'm just traversing down to the object and through the array to get the value.
Naturally, I don't have your exact flow but if I use your JSON and load it up into Parse JSON step to get the schema, I am able to get the result. I do get a different schema to you though so will be interesting to see if it directly translates.

Is it possible in XPATH to find an element by attribute value, not by name?

For example I have an XML element:
<input id="optSmsCode" type="tel" name="otp" placeholder="SMS-code">
Suppose I know that somewhere there must be an attribute with otp value, but I don’t know in what attribute it can be, respectively, is it possible to have an XPath expression of type like this:
.//input[(contains(*, "otp")) or (contains(*, "ode"))]
Try it like this and see if it works:
one = '//input/#*[(contains(.,"otp") or contains(.,"ode"))]/..'
print(driver.find_elements_by_xpath(one))
Edit:
The contains() function has a required cardinality of first argument of either one or zero. In plain(ish) English, it means you can check only one element at a time to see if it contains the target string.
So, the expression above goes through each attribute of input separately (/#*), checks if the attribute value of that specific attribute contains within it the target string and - if target is found - goes up to the parent of that attribute (/..) which, in the case of an attribute, is the node itself (input).
This XPath expression selects all <input> elements that have some attribute, whose string value contains "otp" or "ode". Notice that there is no need to "go up to the parent ..."
//input[#*[contains(., 'otp') or contains(., 'ode')]]
If we know that "otp" or "ode" must be the whole value of the attribute (not just a substring of the value), then this expression is stricter and more efficient to evaluate:
//input[#*[. ='otp' or . = 'ode']]
In this latter case ("otp" or "ode" are the whole value of the attribute), if we have to compare against many values then an XPath expression of the above form will quickly become too long. There is a way to simplify such long expression and do just a single comparison:
//input[#*[contains('|s1|s2|s3|s4|s5|', concat('|', ., '|'))]]
The above expression selects all input elements in the document, that have at least one attribute whose value is one of the strings "s1", "s2", "s3", "s4" or "s5".

Why isn't my report changing the sorting based on the input radio button being toggled?

I have a report that I want sorted differently based on 2 radio buttons (boolean input parameter). If the true radio button is selected, sort by Sum(Fields!plannedPallets.Value), otherwise sort by Sum(Fields!lbrHrsPlanned.Value). However, I'm having trouble with the syntax to use in the expression for sorting the group.
This is what I've tried:
="Sum(Fields!" & IIF(Parameters!PalletSorting.Value = True, "plannedPallets", "lbrHrsPlanned") & ".Value)"
...but this has no effect on the sorting. My guess is because I'm returning a string here when it's expecting something else.
Figured it out. It was simply:
=IIF(Parameters!PalletSorting.Value = True, Sum(Fields!plannedPallets.Value), Sum(Fields!lbrHrsPlanned.Value))

using an expression to show or hide rectangle based on a parameter value (SSRS)

Trying to show/hide a couple of rectangles in SSRS based on an expression which uses the value of a parameter in the report. See the screenshots for more details. When the '-Cover pages' label is picked I want it to display the rectangle but I consistently get the following errors. It can't seem to convert and read the parameter expression no matter what I do.
The expression I'm trying to use is:
=iif(Parameters!specparam.Value="-Cover Pages",true,false)
It looks like the label of your parameter is what you're looking for based on the image provided and your expression. Try to switch instead to:
=IIF(Parameters!specparam.Label="-Cover Pages",TRUE,FALSE)
(Note: I switched specparam.Value to specparam.Label.
Your comment is very close. Apply this expression to the Hidden property of the rectangle:
=IIF( Parameters!specparam.Label.Equals("-Cover Pages"), FALSE, TRUE )
You'll notice I have switched around the FALSE and TRUE as you don't want the rectangle to hide when the parameter matches.
Edit:
As you're dealing with a multivalue parameter, you can use a combination of Array.IndexOf and Split to check if your value is one of the selected parameters.
Apply this expression to the Hidden property of your rectangle:
=IIF( Array.IndexOf( Split( Parameters!specparam.Value, "," ), "-Cover Pages" ) > -1, FALSE, TRUE )

How to set in Report the TextBox visibility by expression in VisualStudio?

I have a simple TextBox in my Precision Design related to a Field in Temporary Table.
I need to show this TextBox only If the it value under Temporary Table is pupulated : so if the value field is pupulated (is a string) I show the Text Box , otherwise I don't show the text Box.
I need to set Visibility by Expression :
Which is the best way forward over ?
Thanks!
You can use iif function. Press fx button, here you can writte your code.
iif function evaluate a condition and return 1 of 2 options, for example, in your case you need show one value only if exist.
check this code:
=iif(fields!YourFieldName.value = "", true, false)
if your field is a number
=iif(fields!YourFieldName.value = 0, true, false)
This code evaluate the value of your field and only populate the value if is complete.

Resources