how to re-use a string across parameters in Power BI - powerbi

I am creating a report in Power BI Desktop. Let's say that I have the following two Excel sources for a report:
'some super long path'\Excel_file1.xlsx
'some super long path'\Excel_file2.xlsx
As usual (to make report maintenance easier), I create two parameters (one for each source). But, since 'some super long path' is the same path in both sources / parameters, I'd like to make that path / string re-useable as well, so that I don't have to re-type it for both sources / parameters. (For two sources, this isn't a big problem. But, my actual report requires about 20 sources.) Is there a way to make this string re-useable? My idea is something like:
parameter A = 'some super long path'
parameter B = parameter A + '\Excel_file1.xlsx'
parameter C = parameter A + '\Excel_file2.xlsx'
But, that doesn't seem to be permissible in Power BI Desktop. As far as I know, the "list" solution (create parameter for 'some super long path', create list holding the Excel workbook names, create parameter that queries the list) won't work for me, as it requires a current value (a value that must be used by both sources), which defeats the purpose.

You can simply use three different parameters
parameter RootDir = 'some super long path'
parameter B = 'Excel_file1.xlsx'
parameter C = 'Excel_file2.xlsx'
Then in queries you can concatenate them to create your file paths.
let
FileName = RootDir & "\" & B,
Source = ...
in
Data

Create a new blank query and place the constant in there.
e.g.
let
Source = "some super long path"
in
Source
Then reference the constant concatenated with the parameter when you need the full file path.

Related

Power Bi web.contents Variables

Please excuse my lack of knowledge in explaining my problem as i have only just started learning Power Bi.
I am attempting to return data by using a dynamic variable within my source url.
Source = Json.Document(Web.Contents("https://api.****.com/jobs/{ID}/invoices", [Headers=[Authorization="Bearer "&GetToken()]]))
I have successfully returned the data i needed from multiple queries Blank Query 1 Query Names
However, i am trying to run a final query in which a job ID needs to be specified.
Source = Json.Document(Web.Contents("https://api.****.com/jobs/{ID}/invoices", [Headers=[Authorization="Bearer "&GetToken()]]))
With the bold item being the variable.
I have successfully returned values by hard coding the variable (seen below).
Hard coded variable
However, i would like to make dynamic in that it will return the values for all the Job ID's witin the "jobs" table.
Job Id's
I don't know if what im asking is possible, or if my explanation is good enough, but any help would be greatly appreciated!
What you are looking for is a custom function.
Make a function out of your above query by adding (ID) => in the first line and separating "ID" in your URL string.
(ID) =>
let
Source = Json.Document(Web.Contents("https://api.****.com/jobs/{" & ID & "}/invoices", [Headers=[Authorization="Bearer "&GetToken()]]))
in
Source
Of cause you can add all your other transformation steps too.
Now take your JobIDs table and add a column by invoking a custom function, select the above function and take the ID parameter from your ID column.
For every row you'll get a separate table and all that's left is simply expanding these tables into your query.
This will solve your problem.

Including parameter expression

I'm new in Informatica PowerCenter, trying to use a new declared parameter expression in Workflow Session parameter file.
Objective: the expression is being feed automatically from data base, so the reason behind all this is to be able to change the logic in db, parameter file will re-generate in the next run with the new logic which ultimately will cause not to change nothing in power Center, only record expression in db. Off course for new fields you will need to change informatica.
Let me summarize or try to be deatailed as posible.
Parameter file has no issues, when executing the workflow it's being read with out issues, here's an example of the parameter expression I'm trying to use (rest of them, dbCon, time etc i delete them)
[Example.WF:Example.WT:.ST:Example]
$$Param_checker=IIF(1=1,'A','B')
Mapping
Created the parameter in the mapping as:
Name: $$Param_checker
Type: Parameter
Data Type: String (as per doc)
Precision: 10000 <-- making sure there's no cut
IsExprVar: true
Created a field in a Transformation Expression Box (the violet one) as:
Name: out_param_checker
Data Type: String
Precision: 10
O: X
Expresion: $$Param_checker
Workflow
In it session reads correctly the parameter file of the Mapping replaces all variables but when it comes to $$Param_checker it's not being expanded, this is a sample of log outcome when inserting on data base (cast and allfunctions are done by Inf. aut.:
CASE WHEN CAST('$$Param_checker' AS VARCHAR(4000))
And off course in Data base when process finishes I see the string as well '$$Param_checker'
Just in case, and sorry for being verbose, I do already have a parameter with a expression working but in a source Qualifier using it on a SQL statement.
The issue is why can't I use it in a out field. Forgot to mention that we have redshift under the hood, all sessions are set to "Full" Optimization, hence I think that's the issue.
If anyone have any hint would appreciate it.
Thanks

How do I rename a sharePoint file to include a date using Nintex

I'm trying to use a 2 workflows to archive any files when created or updated. The first simply moves a copy to a separate doc library. no issues
The second should rename the file once it arrives to append a date (and possible timestamp) to the end of the file so that it is a unique record.
I am trying to set a variable called Archive_Name and then setting the field value to the Archive_Name before commiting the change.
I am using this fomula to set the variable
Name-fn-FormatDate(Current Date,yyyy-MM-dd)
Both Name and Current Date are recognised variable.
When I run this the Name stays the same and does not append a date. If I run it as
fn-FormatDate(Current Date,yyyy-MM-dd)
the Name changes to my desired date proving that the formula is working, the text is being assigned to the Archive_Date variable and the variable is being applied to the field value.
What am I doing wrong?
I believe you need to concatenate the two variables. The & operator can be used in place of the CONCATENATE function. Thus; Name&fn-FormatDate(Current Date,yyyy-MM-dd)
Hope this helps

Setting Variable values after reading file contents

I have a very large query which is getting called from 3 different pages.
Instead of writing the same query in all the 3 cfm files, I am trying to find an alternative way to save the query (alongwith #variable(s)#) in a Query.cfm file.
Query.cfm example :
SELECT *
FROM A
WHERE TRADE_DATE BETWEEN to_date('#f_startDate#','dd/mm/yyyy') AND to_date('#f_endDate#','dd/mm/yyyy')
variables : #f_startDate# and #f_endDate#
Then I read the filecontents, store it in a variable and replace the #variable(s)# with the values to run the function from each of the pages.
Calling page (code so far which is not working):
<cffile action = "read" file = "#ExpandPath( './Query.cfm')#" variable = "Query">
<cfset Query = #ReplaceList(Query,"#f_startDate#,#f_endDate#", "01/01/2000,01/01/2002")#>
<cfquery name="Q_DailyPrice" datasource="#f_datasource#">
#PreserveSingleQuotes(Query)#
</cfquery>
How to set the variable values into the string?
Further details about each page:
Returns the JSON of the query to load charts
Used to generate query data in xls
Used further to generate subset of the query data (QoQ) to create a table.
Database : Oracle
Your options include:
Put the query in a .cfm template and access it with cfinclude
Put the query into a user defined function in a .cfm file. Then cfinclude the file and call the function.
Put the query into a user defined function in a .cfc file. Then you can either run the function with cfinvoke, or create an object and then call the function.
There are probably other options as well. I suggest looking at the three I suggested and determine which one best meets your needs.
Whatever method you use, ColdFusion has a parsedatetime function that will convert your strings to date objects. Using these might be faster that oracle's to_date function. You'll have to test and see. In any event, use cfqueryparameter for a variety of reasons.
Also, be careful about using between with oracle. Its date fields include a time component. If any of your records have one, you are safer with
where trade_date >= YourStartDate
and trade_date < TheDayAfterYourEndDate

"operator does not exist character varying = bigint" in GnuHealth project

We are developing the module in tryton based on GNU Health.We got the following error :
ProgrammingError: operator does not exist character varying = bigint
Hint: No opreator matches the given name and argument type(s). You might need to add explicit type casts
As best as I can vaguely guess from the limited information provided, in this query:
"SELECT name,age,dob,address FROM TABLENAME WHERE pmrn=%s" % (self.pmrn)
you appear to be doing a string substitution of a value into a query.
First, this is dangerously wrong, and you should never ever do it without an extremely good reason. Always use parameterized queries. psycopg2 supports these, so there's no excuse not to. So do all the other Python interfaces for PostgreSQL, but I'm assuming you're using psycopg2 because basically everyone does, so go read the usage documentation to see how to pass query parameters.
Second, as a result of failing to use parameterized queries, you aren't getting any help from the database driver with datatype handling. You mentioned that pmrn is of type char - for which I assume you really meant varchar; if it's actually char then the database designers need to be taken aside for a firm talking-to. Anyway, if you substitute an unquoted number in there your query is going to look like:
pmrn = 201401270001
and if pmrn is varchar that'll be an error, because you can't compare a text type to a number directly. You must pass the value as text. The simplistic way is to put quotes around it:
pmrn = '201401270001'
but what you should be doing instead is letting psycopg2 take care of all this for you by using parameterized queries. E.g.
curs.execute("SELECT name,age,dob,address FROM TABLENAME WHERE pmrn=%s", (self.pmrn,))
i.e. pass the SQL query as a string, then a 1-tuple containing the query params. (You might have to convert self.pmrn to str if it's an int, too, eg str(self.pmrn)).