Binding TRANSFORM query in Access to a report - sql

Whats the best way to bind variable column names to a report field in Access when using a crosstab query?

This page has an exhaustive example of setting up a dynamic column ("crosstab"-type) report in Access.
http://www.blueclaw-db.com/report_dynamic_crosstab_field.htm
(From google search: access transform query report)

The best article I found for binding columns from a crosstab query to a report is from ewbi.develops's notes.
Specifically,
PARAMETERS foryear Short;
TRANSFORM Sum(mytable.amount) AS total
SELECT mytable.project
FROM mytable
WHERE mytable.year In ([foryear],[foryear]+1)
GROUP BY mytable.project
PIVOT IIf(mytable.year=[foryear],"thisyear","nextyear") IN ("thisyear", "nextyear");
This only displays two columns that can be bound as needed.

Related

How to Create Dynamic Columns in SSRS Report

I need to create a SSRS report like
And I have table with 3 columns
DeveloperName,TimeWorked, Date
How can I create the report and what would be sql query to fetch data? I am not asking for complete SQL query I just need some hints.
You can use Matrix (instead of tab-lix) to generate dynamic columns. There is no changes required in your sql query for matrix report (its just a list of DeveloperName,TimeWorked, Date) , but the Matrix control in the SSRS will handle all this. You can refer the below inks
http://ssrstutorials.blogspot.in/2012/10/lesson-15-ssrs-matrix-reports.html
or
https://msdn.microsoft.com/en-us/library/dd207149.aspx

Dynamic Parameter in Power Pivot Query

We are using Excel 2013 and Power Pivot to build modules that consist of several Pivot tables that are all pulling data from the same Power Pivot table, which queries our T-SQL data warehouse.
In an effort to simplify and fully automate this module, we wanted to create a text field that would allow a user to enter a value (a client ID# for example), and then have that value be used as a parameter in the Power Pivot query.
Is it possible to pass a Parameter in the Power Pivot query, which is housed in a text field outside of the query?
You can also pass a slicer or combobox selection to a cell. Define a name for that cell. Put that cell (and others if you have multiple text variables to use) in a table. For convenience, I usually name this table "Parameters". You can then 'read in' the parameters to your query and drop them in your query statements.
The code at the top of your query to read these parameters in might look like...
let
Parameter_Table = Excel.CurrentWorkbook(){[Name="Parameter"]}[Content],
XXX_Value = Parameter_Table{1}[Value],
YYY_Value = Parameter_Table{2}[Value],
ZZZ_Value = Parameter_Table{3}[Value],
Followed by your query wherein instead of searching for, say a manually typed in customer called "BigDataCo", you would replace "BigDataCo" with XXX_Value.
Refreshing the link each time a different customer is selected will indeed be a very slow approach, but this has worked for me.
Rather than pass a parameter to the data source SQL query, why not utilize a pivot table filter or slicer to do allow the users to dynamically filter the data? This is much faster than refreshing the data from the source.
If for some reason you need to pass this directly to the source query, you'll have to do some VBA work.

How to execute dynamic query in anypoint studio?

currently I am trying to create one application using Any point studio. But stuck here...
I am having two select query to fetch the data from two different tables of a single database and according to the request it will decide from which table the data will be fetched.
I'm able to create the dynamic query which will take the dynamic table name and column name. But, I wanted to take two different query. As the column name in the where clause is different for both.
please help me out...
Thanks
You should be able to use MEL expressions in the database connector by choosing "Dynamic" type select query. So you only have to put the correct clause on a string variable and reference it on the connector.
Anyway, I would not try that approach. I would place a "choose" flow control and two database connectors and decide which of them use base on your condition. I would use "Parametrized" type select query, it is more secure than using "Dynamic".
Best regards,
José

SSRS 2008/2012 - ADDING AGGREGATION FIELDS

I'm attempting to add a field to an SSRS report based on 2 other displayed fields.
I'm using a matrix report
Field One is a Count of Account numbers
the Second Field is an Order Amount
My Attempt
New_field=(Sum(Amount))/(Count(Account))
What is the best way to do this in SSRS. Because one cannot have Aggregate functions in SSRS.
A second and related issue is Percent increases. What would be the best way to generate Percent differences in a new column.
Notes:
1. The report is fueled using a SQL Stored Procedure.
2. Graphical Display vs tabular are acceptable
Thanks
You can simply put your formula in query and give it an ALIAS. I've also use CASE statement to catch the error when Count(Account)=0.
SELECT
CASE WHEN Count(Account)=0 THEN (Sum(Amount))/(Count(Account)) END AS New_field
FROM TableName

How do you do a crosstab query in Access with a fixed amount of columns

I want to pull data with an MS Access crosstab query so I can bind it to a report. When I load the page I get a Run-time error'3637': Cannot use the crosstab of a non-fixed column as a subquery.
I would like a way to get back a fixed grid when I run the query and if the cell is null display a zero.
Subquery? That's one of my weaknesses when it comes to Access so I can't help you there. I'd suggest posting the SQL of the query though so others can take a look. Also what happens when you run the query?
The following is a query that I'm using to give me costs for the last ten years for a given unit.
TRANSFORM Sum(ServiceRecords.srTotalCost) AS AnnualCost
SELECT ServiceRecords.srEquipmentID
FROM ServiceRecords
GROUP BY ServiceRecords.srEquipmentID
PIVOT "C" & DateDiff("yyyy",[srServiceDate],Date()) In ("C9","C8","C7","C6","C5","C4","C3","C2","C1","C0");
The trick is after the PIVOT. As I want the last ten years worth of data the "C" & DateDiff portion sets up a string variable call C0 to C9. The portion after the In tells which column to stuff things into.
Another query which pulls in data about the Equipment calls this query. The term we generally use for such is stacked queries.
If this isn't enough to get you going please indicate what type of data you are trying to create a cross tab.
Fellow Access MVP, Allen Browne has a good page on this topic. Crosstab query techniques