I use PowerBI (October 2020), and I have one dashboard with a drop down DATE slicer. I have two problems with it:
I need to pass the value of slicer to a stored procedure to use there as a where condition. I mean the query has used in stored procedure, filtered by the date has picked in slicer.
I need keep update the value of slicer too. I means if today is 2021/08/10, this date shows in slicer and tomorrow is become 2020/08/11 automatically.
If somebody can provide some solution that would be great.
Thanks in advance
1).
You have to create 2 parameters for selecting data range if you use stored procedure.
Similar thing happen to me earlier, so I switched from stored procedure to mysql or sql views. I managed to get data via join queries and optimize it.
Because if you use Views you have some limitations.
If you have correct requirement hardcode lower bound date, and if you use view it act as mysql table.
2).
If you have date slicer in the filters you can change it to relative date to selected time, then your upper bound date will update accordingly.
After hours of testing I have the strong opinion that it is not possible to call SQL stored procedures with parameters and DirectQuery, affected by user controls in a PowerBI dashboard.
This is easily done in PowerBI Report Builder.
You can create parameters in PowerBI that affect the parameter-values in your SQL-stored procedures but they are not adjustable by the user in your dashboard.
The syntax for the call to SQL SP is:
let
Source = Sql.Database("[server]", "[database]", [Query="EXEC direct.sp_[stored procedure] '" & DateTime.ToText(prmStartDatum) & "', '" & DateTime.ToText(prmEindDatum) & "'", CommandTimeout=#duration(0, 0, 10, 0), HierarchicalNavigation=true, MultiSubnetFailover=true])
in
Source
The error you get is:
Microsoft SQL: Incorrect syntax near the keyword 'EXEC'. Incorrect
syntax near ')'.
When this is fixed, it would be a great improvement to PowerBI dashboards.
Related
Good day to everyone! Hope all is well!
I am looking to run an update query or a group of queries that looks at my Date_Start and Date_End to determine if the Units (quantity of the respective record) fall in my defined current quarter 1/2/3/4 from another table (this table is a master table I’m using to provide the dates that I need to consider for defining the quarters).
I’ve been able to create queries that do this and then join them together to basically display the units out by quarter based on their respective start/end dates. The problem I am running into is this process takes a decent amount of time for the queries to populate that will drastically effect other processes down the line.
Thus we get to my desire. I am trying to no avail to create an update query that will update the quarter fields in my table based off of the queries I built to determine if the records start/end date fall in the respective quarter. I figure that running this update when records change will be an ok run time vs when I’m running reports or running an email script for the reports.
I have tried pulling in the table and query, joining them as equal on ID (the query pulls in the table's IDs), and selecting my field “CQ1” from the table, and setting the Update ether the respective field from the table or the query (which is the same as the field in the table).
All I get are the current values of the field in the data sheet view and an error of “Operation must use an updateable query.”
I have even tried placing a zero to see if that would do it with no luck. I have verified that all the fields are the same data type.
What am I doing wrong? Thanks!
Apologies to everyone.....I think my conscious brain was trying to overly complicate the process and while talking to a buddy about my issue distractedly created a new update query that worked. It all tied down to that I forgot to put a criteria on my quarter filed of is not null I believe. Thanks for anyone that has read this and is responding while I’m typing this or for those of you formulating a response.
I am using google-cloud-bigquery gem for my Ruby on Rails application. I am able to execute the query on the dataset and do the following
Execute query
Create destination table and store results into it
Store the final results into a file from a destination table
Now I want to set the expiration time for the destination table. I find a document to updating a table. But I am unable to find a way to set the expiration time using Ruby language?
Also I am able to fetch expires_at value from a table which returns nil. I don't find a way to set it.
Kindly help
I'm no Ruby expert, but I also cannot find anything in the docs/api that allows you to set the expiration on a table. You can do it at the dataset level (here) or for partitions on the table (here). It looks like it's not exposed via the client library for some reason.
Another way of doing it is via DDL in SQL e.g:
ALTER TABLE mydataset.mytable
SET OPTIONS (
expiration_timestamp=TIMESTAMP_ADD(CURRENT_TIMESTAMP(), INTERVAL 7 DAY),
description="Table that expires seven days from now"
)
While querying BAPI, we are generally interested in only few columns of a table.
For example PO_ITEMS table (under BAPI_PO_GETITEMS) has 58 columns. While querying, I am interested in only 10 of those columns. But the BAPI response contains all the columns which is a
overhead.
In SQL world, we can always select which columns we want to retrieve. The query response contains only those columns, not all the columns.
I remember I have read somewhere that we can disable unwanted columns coming in response. But when I need it now, I am not able to find information about it.
Can anybody share a code snippet to achieve this? Or specific online resource/pointers would help?
Thanks
Depending on which technology you use to call the BAPI, you can sometimes restrict which parameters are transferred. For example, if you use the SAP Java Connector (JCo 3), you can use the method setActive of a parameter to restrict whether the parameter is transferred. However:
As far as I know, you can only enable or disable entire TABLES parameters or other parameters. You can't enable or disable individual columns.
As far as I know, the BAPI itself does not know about this setting - and even if it would know, few implementations would care.
Sometimes there are additional parameters that allow you selectively enable or disable fields, but that is part of the actual BAPI implementation and not some omnipresent basic technology.
this is not exact answer for your question.i hope it will help.I think we have no option to select certain number of column from a function module tables.but we can access particular row from that table like passing mandatory values from java side .....like this sample code here i did for function module(not table table).
JCoDestination destination = JCoDestinationManager.getDestination(DESTINATION_NAME);
JCoFunction jf=destination.getRepository().getFunction("ZUSER_DET");
jf.getImportParameterList().setValue("FIRST_NAME","username");
jf.execute(destination);
String jfex=jf.getExportParameterList().getString("some column name from return table");
System.out.println(jfex);
it will return a row of table value.you can manipulate whatever you want
Is it possible to connect to Google Spreadsheet in GAS using SQL-type queries? If so, any working samples?
Thanks.
Depending on what you want to do, there are two options.
1) You can have a SQL Database and connect to it using the Jdbc Service ( https://developers.google.com/apps-script/service_jdbc ).
2) The other option, which I've used once earlier, is by making use of the QUERY() function. You can set the formula on a cell to the SQL like query and then read the subsequent cells.
( https://support.google.com/docs/bin/answer.py?hl=en&answer=1388882 ).
Update after Google I/O 2012:
As you might have already noticed, Google possibly heard you and introduced ScriptDB which is better than the two options mentioned
You can also used the "Structured Query" parameters available in the Spreadsheets API to make calls like: &sq=filter:7 where filter is the name of your column and you want to return the results of any row where the value in that column is 7. See the List Feed section of the Spreadsheet API.
The company I work for is using MacolaES for an ERP system. The SQL Server database is structured such that when things are no longer considered active, they are moved from a set of "active" tables to a set of "history" tables. This helps to keep the "active" tables small enough that queries return quickly. On the flip side, the history tables are enormous. The appropriate columns are indexed in these tables, and if you query for something specific it returns quickly.
The problem is when you make a Crystal Report, which is prompting the user for a parameter. For reasons not known to me, Crystal parameters are not translated into SQL parameters, so you end up with queries selecting everything from the order header history table inner joined to everything in the order lines history table, which results in over 8 million rows.
Is there a way to get Crystal Reports to use the parameters in the SQL query instead of loading all the records and filtering after the fact? I read somewhere that a stored procedure should work, but I'm curious if an ordinary parameterized query is possible in the interest of saving my time.
Here is the selection formula:
(
trim({Orderheader.ord_no}) = {?Order No}
)
and
(
{Orderheader.ord_type} = 'O'
)
and
(
{orderlines.ord_type} = 'O'
)
In Crystal Reports top menu go to Report / Selection Formulas / Record... There you can add a formula similar to:
{table.field1} = {?Parameter1} and {table.field2} = {?Parameter2}
That will add the condition to the where statement of the SQL query that the report will use to pull the rows.
To verify what is the condition in the where statement that the report is using to pull the data you can go to the menu database / Show SQL Statement. That way you can verify that the report is using the parameters in the filter.
Crystal Reports 8.5 User Guide mention the following tips:
To push down record selection, you
must select “Use Indexes or Server for
Speed” in the Report Options dialog
box (available on the File menu).
In record selection formulas, avoid data
type conversions on fields that are
not parameter fields. For example,
avoid using ToText( ) to convert a
numeric database field to a string
database field.
You are able to push down some record selection formulas
that use constant expressions.
Your formula has a TRIM function on a field. The function against the field does not allow Crystal to push the formula to the database because is not a constant expression.
If you really need to trim the order number field you should do it using SQL Expressions.
References:
Check out this article.