Ms Access Criteria Checkbox with HAVING IIF Statement - criteria

I can't get the "Less Than" criteria correct for the false part of the IIf statement: <=[Forms]![BuildLocationKey]![Building1].[value]. This is fed with 8 other rows to another query which outputs a list of sequential temporary numbers that are printed out as a location identification. Using the Criteria box as I haven't had any luck this working with VBA, but am open to any suggestions.
[BuildCB] is the Checkbox
SELECT DISTINCT Building.Bu
FROM Building
GROUP BY Building.Bu
HAVING (((Building.Bu)=IIf([BuildCB],[Forms]![BuildLocationKey]![Building1].[value],"<=[Forms]![BuildLocationKey]![Building1].[value]")));

Related

From group by to window function postgres

my goal is to compare Event Engagement Rate = ( Event Subscribed / Event Participated ) for the newsletter source vs Email Source by using window functions
i Managed to do it by using group by
select source ,sum(event_subscribed/event_participated) as "engagement rate" from events
group by source
i keep failing with the windows function by having too many rows and wrong engagement rates
Thanks for your help.
First you need to understand the difference between the Aggregate functions and the Window variant of the same function. The aggregate functions builds groups as specified in the 'Group By' clause and reduces the result to a single row per group. The Window version also builds groups as specified in the 'Partition By' clause. However, it does not reduce the number of rows, instead it generated the same result in each of the rows within the group. See example. To reduce the Window version to a single row per group use Distinct on expression.
SELECT DISTINCT ON ( expression [, ...] ) keeps only the first row of
each set of rows where the given expressions evaluate to equal. The
DISTINCT ON expressions are interpreted using the same rules as for
ORDER BY (see above). Note that the “first row” of each set is
unpredictable unless ORDER BY is used to ensure that the desired row
appears first.
Your query becomes
select distinct on (source)
source
, sum(event_subscribed/event_participated) as "engagement rate"
from events
order by source.

SSRS -How to get month name from integer value when connecting to IBM-DB2(AS400)

I am using SSRS to create a dataset from a query having a column in AS400 with month number which i get based on a condition .i am able to get the month number . But when i try to get month name SSRS does not accept the query .However if i run the same query on AS400 the query successfully runs
To test my query i ran it in AS400 using MONTHNAME(MONTH) it runs successfully however SSRS does not accept the same query as correct.Below is my query.
SELECT DISTINCT SLMONTH, MONTHNAME(SLMONTH) AS Expr1
FROM VEHICLE.VHTSALSUM
WHERE (SLMGCD = ?) AND (SLMODLCD = ?) AND (SLMODLYR = ?) AND (SLYEAR = ?)
Instead of doing this in on the server, you could just return the month number to SSRS and use an expression to convert it to the month name there.
The expression would simply be
=MonthName(Fields!SLMONTH.Value)
This assumes AS/400 returns month numbers 1 - 12
Personally I think this is a better approach anyway as it means you have the month number to sort by. It is usually better to do your presentation in the report itself.
Edit based on feedback:
To do this for use in a parameter..
Create a dataset that returns just your month numbers.
Right-Click the dataset name and go to properties
On the Fields Tab, add a new field called MonthName for example
Click the function button for the field source type the expression =MONTHNAME(Fields!MonthID.Value)
The month name will then be available directly in your dataset for use in your parameter

Filter on Group Expression using lookup to second dataset. SSRS 2012

I have two datasets (one is a stored procedure written by a vendor that cannot change). Stored procedure is the main dataset. I am using a second data set to bring back filtered results. The second dataset contains already filtered records.
Trying to use the Tablix filter:
=Lookup (Fields!UserGUID.Value,Fields!UserGUID.Value,Fields!MembershipPolicyGUID.Value, "Dataset2")
I have a group that needs to display only the records in Dataset2.
Dataset2 is written using a where statement only displaying
MembershipPolicyGUID not in'00000000-0000-0000-0000-000000000000' and '29976BA0-E2D7-494E-A1CE-20E609C76929' (these numbers are stored as text)
I need help in how to filter the records.
I have tried the <> in the Tablix filter using the above expression, but it does not work or rather it does not return any records from Dataset2 except those from Dataset1.
Figured it out. The filter should be:
expression =Lookup (Fields!UserGUID.Value,Fields!UserGUID.Value,Fields!MembershipPolicyGUID.Value, "Dataset2")
then operator >
then value 0

jaspersoft print specific records from csv file

I have a Label set up in Jaspersoft Studio that references a data adapter file in CSV format. The csv file contains thousands of records. I want the end user to be able to select or key enter the "order no" for the specific records to print. If one order no is entered - record is found and printed. If ten order no's are entered - 10 records will print.
Thank You.
You could use Parameters to let user make input. But because CSV is not query language, you can use Field Expression in Data Source
Here's how to add Parameter
https://community.jaspersoft.com/wiki/using-report-parameters
And this is how to use Field Expression
https://community.jaspersoft.com/wiki/how-apply-parameters-csv-data-source
Detail: Filter by attribute:
In query dialog, you select Filter Expression tab and fill the field with code like this
$F{order_no}.equals($P{order_no})
This code will filter the csv row that has order_no field that equal to order_no parameters
Filter by multiple order_no:
JasperReport are allowed user to do some scripting in Java or Groovy (depending or their settings). So you can do more complicated task like split input into array and use it to search rows.
What I have in mind, are ask end user to seperate order_no by space and use this script to filter the data.
Arrays.asList($P{order_no}.split(" ")).indexOf($F{order_no}) > -1
I have not tested this code yet, but hopefully you get the idea. (Experiment with the script).

How to Interactive Sort by Calculated Columns in SSRS 2008

I have a calculate field Total Pts which is the sum of the values of report items
=ReportItems!Textbox28.Value + ReportItems!Textbox30.Value + ReportItems!Textbox32.Value
Now I want to put a interactive sort here and I am not able to do so . Any ideas? I can't do it in a query because the reportitems that I am adding are from a two different datasets which are of diff. types eg: sql server & sharepoint
There should be no issue with doing this because SSRS allows you to use an expression to determine the sort order. Just right click on your header textbox for the column and go to the interactive sort tab. Here you can turn interactive sort on, then in the sort by field click the function icon next to the drop down. Use the same expression that you used for your calculated field, and it will sort according to the results of this expression. If there is some reason you can't do this that I'm missing, let me know and I'll try to help.