Error when loading data into PBI Desktop - powerbi

I've created a function from a query that fetches the weather forecast from darksy.net API.
Basically, I pass the latitude and longitude as a single parameter to the query and I get a weather forecat.
The parameter is entered as text in the form of "lat,long". Eg: Lisbon is ‎38.736946,-9.142685
Everything works fine, the data is loaded into Power Query. However, when hitting "Close and Apply" button I get the error:
It seems the URL is adding E2%80%8E before the parameter.
I tried 2 differente APIs (darksy.net and http://api.openweathermap.org) and the problem happens in both.
Why is this? Can anyone help?

Related

Dynamic query (Current date) via web services in Power Bi

In my project we are consuming the company's data via Web Service REST. Today we don't do the query dynamically by passing the start date and end date parameters via string.
enter image description here
My goal is for the end date to update dynamically. I've already created a query that takes the current date but I can't put it in the parameter without generating an error in the query.
enter image description here
This is the error message I get when I put the column value in the parameter:
enter image description here
I'm pretty sure I'm getting the syntax wrong. Anyone who can help me, I really appreciate it. I would like to point out that the date format for the API call to work is DD/MM/YYYY.
Can you try using
PutYourOtherTableNameHere[Hoje_Coluna]{0}
instead of
[Hoje_Coluna]
?
To see if that will work, put this in right before your query, then click on the step and see what it returns.
x = PutYourOtherTableNameHere[Hoje_Coluna]{0},

How to change a database name in a query via a URL in power bi

i am trying to change my database name in my advanced editor query in power bi. I know i can create parameters with in the power bi desktop app and pass the different database with in it. I have done this and it works fine.
But what i am trying to do is when i give a user a link for example
https://app.powerbi.com/groups/me/reports/DataSource="PowerBi_1"
how do i get the datasource name which is "PowerBi_1" and pass it into my advanced editor query which looks as follows
let
Source = Sql.Database(".", "PowerBi_2", [Query="select *#(lf)from Customer"])
in
Source
so i want to replace the Powerbi_2 with PowerBi_1
is this possible?
I tried searching and the only things i could find was to add parameters from "manage parameters" which i can already do. But i need it to be passed from the URL and automatically change the data source instead of manually changing it via "edit parameters"
i know you can use filter in your URL as https://app.powerbi.com/groups/me/reports/12345678-6418-4b47-ac7c-f8ac7791a0a7?filter=Customer/PostalCode eq '15012'
but this would only work on datasets. im not sure how to do this for a database change in a query
The only thing you could try is if you have a direct query and use the new feature of binding query parameters.
https://learn.microsoft.com/en-us/power-bi/connect-data/desktop-dynamic-m-query-parameters
Then you can set a filter with url to point to the database you need. Not sure how it would work - haven't tried it myself.
To expand on the idea a bit - you would need a table with database names in it. Then you would bind database column of that table to your query parameter and finally, use your url to set appropriate filter on this new table.
EDIT:
Scratch that, in the article I linked to, it says that direct query T-SQL is not supported. But if they were ;)...

Power BI parameter for image

I wanted to know if there's a way to have a parameter that holds an image.
The problem: I have 10 PBIX, each one containing over 20 screens. every report has the clients logo. it is an image let's say the client changed his logo, that means I'll need to change the logo 200 times!! (10 PBIX X 20 screens).
Wanted solution: is there a way to hold a parameter that will contain the logo, therefore changing the logo only 10 times (for each PBIX) that will be a HUGE improvement for my time and productivity. sorry for not including pictures this is to keep my client anonymous
Thank you!
Here is how you can achieve your requirement as stated below-
Step-1 create a custom function in Power Query as stated below. The function is taken from Here and you can check this blog for more details if you are interested.
let
BinaryToImage = (BinaryContent as binary) as text =>
let
Base64 = "data:image/jpeg;base64, " & Binary.ToText(BinaryContent, BinaryEncoding.Base64)
in
Base64
in
BinaryToImage
Here below is the image for the custom function-
Step-2 create report wise folder in your local directory and keep your image there. I am considering one folder here, but you can do your own once you get the workaround.
Step-3 Create a data connection for Folder as shown below and point to the folder you kept your logo/image-
And now you will have a table as below with one row as there are one image only. I named the table as PBI_Images.
Here basically Content column holding the Binary data for the image and we have to convert it to Base64 using the Function we created earlier.
Step-4 Now lets Invoke the function in our table. Select the table and do what shown in the below image-
Now you have a new column with data like below-
Step-5 Get back to report by clicking "Close & Apply" button.
Step-6 Download the following App from AppStore-
Step-7 Just add the new downloaded visual to your report and put the newly created column to the "Image URL" field as below-
Step-8 Now add the Image visual to all your report pages and tag the Image URL as stated in step-7.
You are all done now. Just Change the Image in your source file keeping the same name and after that refresh your table (PBI_Images my case) and you will see Image changes everywhere in the report.
Finally, if everything works expected, you can first try will all logos from one single folder. If do not work, go for folder per customer as mentioned earlier.

File browse Item uploading to BLOB column

One of the tables in my DB has a BLOB column that stores images. So now I am setting up the page for this table. I have a bunch of IGs and such to process most of the data, but I set up a modal page to process the image.
The modal page gets the ID (which is the PK) into an item, and then it reads the image currently in the table into a 'Display Image' item. And I have a 'File browse...' item to upload new images.
Except I cannot get it to save.
I initially started with the display image item just having Setting Based on : BLOB column returned by SQL statement, as I couldn't get the source to work with the SQL query(Error Expected CHAR, source is BLOB), I managed to resolve this by putting automatic row processing on the page and then having the source be a column.
So now it displays well, with no errors.
But the save does nothing. I have tried saving by having the File browse reference the column and using automatic row processing, and there is just nothing. No errors pop up, but it just does nothing.
I have tried saving to APEX_APPLICATION_TEMP_FILES and then having a PLSQL DA or a PLSQL process to
SELECT blob_content
FROM APEX_APPLICATION_TEMP_FILES
WHERE name = :FILE_BROWSER_ITEM
And insert this into the table, but it just pops up a 'No data found' error.
I have gone through every bit of intel my google-fu has found, but I have failed to find a solution.
So I would appreciate any insight any of you might have.
Since noone answered, I stepped away from it for a bit and tried again at a later date. And now I made it work finaly.
I set up automatic row fetch and automatic row processing but disabled both of them, for some reason automatic row processing must be there so that you can have the source for the display image and file browse be the column.
Then I set the browse file to load into apex_application_temp_files.
and set up a process to be executed at page submit(but after the automatic row processing even though its disabled and shouldnt matter). The process executing the following code:
BEGIN
UPDATE MY_TABLE
SET MY_IMAGE = (SELECT blob_content
FROM apex_application_temp_files
WHERE name = :FILE_BROWSER_ITEM)
WHERE id = :ID;
END;
And I execute the page submit through a button with the action page submit and Database action being SQL UPDATE action.
I am guessing a fair bit of the things I did and have set up dont even matter, but I dont dare remove them for fear of breaking shit. What I have described here finaly works for me, and if you stumble upon this then you can try and I hope it works for you too, and you can try removing some of the disabled stuff and see if it still works.

Podio API - Python filter request

Running pypodio2
I am trying to build a simple script which pulls a set of filtered items with the item filter command. It is for my own personal use to automate invoice generation.
My end game is to filter by a calculated date field - i.e. the field pulls a date from relationship.
However so far can't seem to get my request to filter any values at all. The is a sample of what I would expect to pull all items in the app where the quantity-kg value is 10.
c.Item.filter(14928728,attributes={'filter_by':[{"quantity-kg":10}]})
This returns all the items in the app.
I have tried a few different things but can't seem to work this out.
So first I would like to work out the correct syntax for passing simple request, and then work out how to pass a request to filter by date.
Worked it out, my original code had some mistakes.
'filters' not 'filter_by'
No need to pass a list as the attributes values
Filter values need to be in 'from' 'to' from.
So the code is:
c.Item.filter(14928728,attributes={'limit':500,'filters':{'121293716':{'from':'2‌​016-08-09','to':'2016-08-09'}}})
for the dates, or
c.Item.filter(14928728,attributes={'limit':500,'filters':{'quantity-kg':{'from':‌​10,'to':20}}})
for the value field.