SSRS Switch statements for multiple conditions - if-statement

I'm attempting to use a SWITCH statement in order for Report Builder to tell me the premium depending on the level of cover that's selected for this particular part of a policy.
The statement I'm using:
=SWITCH(Fields!Salon_Stock_Equipment_Cover.Value="NOTREQ", "Not Required",
Fields!Salon_Stock_Equipment_Cover.Value="1500", "22.40",
Fields!Salon_Stock_Equipment_Cover.Value="2500", "33.60",
Fields!Salon_Stock_Equipment_Cover.Value="5000", "39.20")
I'm using this in Report Builder.
I'm expecting the string to return either "Not Required", "22.40", "33.60" or "39.20" depending on the values that are pulled through. When I run it at the moment, it just returns blank.
How can I achieve what I want?

Related

Azure logic apps Odata filter query with if statment on two columns

Good morning,
I have a unique requirement where I have to apply a filter on "Get entities" from Azure table based on a condition, filters come from HTTP get request.
There are two filters - a and b.
If both filters passed to the flow are empty, no filter is applied.
If either one of the filters is not empty, the filter must be applied on that column.
If both filters are not empty, the filters must be applied on both columns.
Is it possible to apply an If statement in an ODATA filter query?
I can't seem to find a good answer.
For this requirement, we can just use "Condition" in logic app to implement it. It's not a smart solution, but it works.
First I use two variables to simulate your two filters from http request.
Then use another variable to store the result filter(s).
Now add a "Condition" to judge if filter1 is not equal to "empty".
If true, add another condition "Condition 2" to judge if filter2 is not equal to "empty" and set the value for filterResult.
If false, also add another condition "Condition 3" to judge if filter2 is not equal to "empty" and set the value for filterResult. Note: use expression string(' ') in "Set variable 4", or it will not allow us to save the logic app.
After that, we can use filterResult in "Get entities". The expression in below screenshot is trim(variables('filterResult')).

AppleScript:IF command doesn't execute

I am a beginner at AppleScript so I really don't know a lot. I have been trying to make the user select from a list of situations and then based on what they choose have an appropriate response. However, I have run into a few problems:
The script runs but doesn't display the notification.
Is there a better way than just chaining a lot of IF statements?
PS: I am nowhere near finishing this whole script.
on run
choose from list {"Thunderstorm", "Flood", "Heatwave", "Hazmat"} with prompt "Please select one of the emergency situations below" without multiple selections allowed and empty selection allowed
return the result as string
if string is Thunderstorm then display notification "hello"
end run
You made some pretty good guesses about what the sample code you were looking at does; but some of those guesses were wrong. With time you’ll get a better feel for how AppleScript works.
You have the situation names entered correctly as strings in the choose from list line, by surrounding their text with quotes. But in the check to see whether it’s a thunderstorm, you do not surround that text with quotes. AppleScript is looking in a variable called Thunderstorm for its contents, not looking at the string of text “Thunderstorm”.
return the result as string does not create a variable called string but rather ends the handler called run, returning the result to whatever code called run, as a string of text. To assign the result of choose from list to a variable, use something like set theSituation to the result as string.
Here’s an example of how your code might work better:
on run
--get the situation we're dealing with
choose from list {"Thunderstorm", "Flood", "Heatwave", "Hazmat"} with prompt "Please select one of the emergency situations below" without multiple selections allowed and empty selection allowed
copy the result as string to theSituation
--Thunderstorms require that the user be immediately notified
if theSituation is "Thunderstorm" then display notification "hello"
end run
Since you have this as a run handler, you probably don’t want to return any result, as you rarely call run handlers. But if you do need to return the result, the last line of the handler (just before end run) would be:
return theSituation
You might look around for an AppleScript tutorial that fits your needs. Apple has their Introduction to AppleScript Language Guide.
IF statements can be chained using if/else if/else if:
on run
--get the situation we're dealing with
choose from list {"Thunderstorm", "Flood", "Heatwave", "Hazmat"} with prompt "Please select one of the emergency situations below" without multiple selections allowed and empty selection allowed
copy the result as string to theSituation
--Thunderstorms require that the user be immediately notified
if theSituation is "Thunderstorm" then
display notification "hello"
else if theSituation is "Flood" then
display notification "hike pants"
else if theSituation is "Heatwave" then
display notification "Play Bing Crosby"
else if theSituation is "Hazmat" then
display notification "Use highway 183"
end if
end run
There is no switch/case control structure in AppleScript.

Tableau: Creating Dynamic Filter to exclude names

I have been working on this for the better part of the day and would like to crowd source as I must just be missing something simple.
I would like to use a parameter control to create a dynamic filter that would exclude the names of individuals that have already participated in an event. For example in the following list of two fields:
Name-Event Name
Carl-Agriculture
Carl-Agriculture
Carl-Agriculture
Jodie-Business
Jodie-Agriculture
Jodie-Agriculture
Pam-Business
Pam-Business
Pam-Business
if the parameter was set to Agriculture, only Pam would show up on the list, and if it was set to Business only Carl would show up. This list will help stakeholders send invitations to potentially interested parties.
I have tried so many calculations including the parameter itself in IF statements, IIF statements, CASE statements, etc. I've also tried creating a second calculation to work off of the first but am still striking out.
Any ideas?
You got most of the way there on your own. To finish the job:
Place Name on the filter shelf
Select "Use all" on the General tab of the filter panel
Select "By field:" on the Condition tab of the filter panel
Choose the "If Exclusion Statement" field, Count aggregation function (NOT Sum in this case), and set the test to "= 0"
The effect of this filter is equivalent to the SQL group by Name having Count(If Exclusion Statement) = 0

Aqua Data studio, compare results, column names case-sensitive

Any Aqua Data studio users out here know how to turn off case-sensitivity when comparing results?
e.g. in one Query, column 1 is called "test", in another one it's called "TEST", then Aqua datastudio does not identify these columns when comparing results. How can I turn this off?
I can ignore upper/ lower case in the result set, but not in the column names.
Renaming every column each time manually is a pain. Somebody knows?
For Results Compare, cant you change your SQL Query to the same case, using Upper or using ALIAS for the column name ? I used for e.g. UPPER("category") AS CATEGORY and this solved the problem you are having.
For Schema Compare do the below
Under File->Options, Compare, enable option to Ignore Case
When you perform a Schema Compare, Under Object Alignment, you can select to Ignore Case

Listing SSRS subscriptions with user-defined descriptions

We have a growing number of non-data-driven SSRS 2008 subscriptions and the default list in SSRS does not provide any way to indicate what each subscription is all about. Yes, there is a description but it is auto-generated and not very helpful. We need it to say "Company ABC Quarterly to Managers", for instance.
I looked at using the ReportingService2010 web service and managed to not only read each report's description but modify it. However, as soon as someone edits the subscription from SSRS, which will be required sometimes, the description reverts to the auto-generated one.
Although I have never worked with data-driven reports, I wonder whether these will provide the functionality that I need. It just seems like a lot of work to set up, given that I don't really need the subscriptions to be data-driven.
Am I missing something simple here? Is this simple functionality something that comes with upgrading to a newer SSRS version?
Thanks!
Am I missing something simple here? Is this simple functionality
something that comes with upgrading to a newer SSRS version?
It does not appear that standard subscriptions in SSRS 2012 allow descriptions to be entered either (I couldn't find a screenshot of the UI though).
Although I have never worked with data-driven reports, I wonder
whether these will provide the functionality that I need. It just
seems like a lot of work to set up, given that I don't really need the
subscriptions to be data-driven.
I would argue against the need for data-driven subscriptions if standard subscriptions are fulfilling the business need. Would this be worth your time and effort? If it is, the obvious advantage is that subscription descriptions are editable in the UI, and do not appear to be overwritten when modifying the subscription.
If you're still interested in using standard subscriptions...
One way to "hack" SSRS such that the subscriptions will not overwrite the description (which isn't editable in the UI anyway) would be to modify the stored procedure ReportServer.dbo.UpdateSubscription.
DISCLAIMER: Use the following advice at your own risk. This involves modifying a standard sproc that Reporting Services relies on.
You can alter the update statement such that the description value would only be modified if the subscription is not a data-driven subscription (we do not want to break data-driven subscription descriptions, which are editable in the UI). In the stored procedure, you can distinguish data-driven subscriptions from standard subscriptions by looking at the value of #DataSettings. If it IS NULL, then it is a plain old subscription. If it IS NOT NULL, then we're looking at a data-driven subscription.
The following line in the Update statement:
[Description] = #Description,
Can be changed to:
[Description] = CASE WHEN #DataSettings IS NULL THEN [Description]
ELSE #Description
END,
This would keep all standard subscription descriptions the same when they are modified in SSRS, but allow data-driven subscription descriptions to be modified.
Per Mat's Mug, I am noting the solution that I eventually used:
Since all of our subscriptions involve emailing the report, we could get away with re-purposing the email subject field as the description. This way it was possible to produce a listing of all subscriptions and show an arbitrary description for each one.
Here's an expansion on the hack from dev_etter. I was able to use the Stored Procedure #parameter input along with a new Report Parameter (pReportParameterName) to create a dynamic, user controllable description that's unique to the report.
Add a new hidden text parameter to the report (pReportParameterName)
Add the Code Block 1 below in Stored Procedure UpdateSubscription above the UPDATE statement.
Change the 'Description = ' line of the UPDATE statement to something like Code Block 2 below.
With that set up, create or edit a Timed Subscription and enter the desired text into the Description parameter. After saving you should see the entered description in the Description column of the Subscriptions screen.
/*** Code Block 1 ***/
DECLARE #Param as XML = CAST(#Parameters as XML)
DECLARE #MY_Description as varchar(512)
SELECT #MY_Description = e.f.value('(.)[1]', 'varchar (100)')
FROM (select 1 id, #Param xCol) tx
CROSS APPLY tx.xCol.nodes('./ParameterValues/ParameterValue') AS a(b)
CROSS APPLY a.b.nodes('./Name') AS c(d)
CROSS APPLY a.b.nodes('./Value') AS e(f)
WHERE c.d.value('(.)[1]', 'varchar (100)') LIKE 'pReportParameterName'
/*** Code Block 2 ***/
[Description] = --#Description
CASE
WHEN #DataSettings IS NULL
AND #MY_Description IS NOT NULL
THEN #MY_Description
ELSE #Description
END,
Cheers,
Sj