Forum Discussion
chriswragge
7 years agoHelper I
Using PowerBI Parameters Names in .txt files, to build dynamic API queries
Hi there, I have a query that uses the PowerBI 'Web' source to pull reporting data from an API (POST method). I also have the client ID, client secrect, body, and token into seperate .txt files ...
- 7 years ago
I just worked it out myself using the same exact logic. You can use this in a function too. Glad you were able to get this working
let Source = (samplebinary as binary) => let Source = samplebinary, ConvertToText= Text.FromBinary(Source,1252), ReplaceParam1 = Text.Replace(ConvertToText,"var1", param1), ReplaceParam2 = Text.Replace(ReplaceParam1 ,"var2", param2) in ReplaceParam2 in Source
chriswragge
7 years agoHelper I
Thanks so much for the help Nishantjain!!
So if i had a .txt file with the text
Hello [var1] Foo [var2]
What would my PowerBI code look like to read this .txt file in and replace
- [var1] with a my PowerBI "Param1" value ("World")
- [var2] with a my PowerBI "Param2" value ("Bar")
Oh, and the synatx of the vars in .txt file could be in any format to make this easier. E.g. "Hello "&var1
Nishantjain
7 years agoContinued Contributor
Chris
I dont have my laptop with me so cant write the whole code from my mobile. But lets try something
Do the following and send me the code
1. Import the text file in a new query
2. Carry out all the steps in that query to create the logic of replacing the values in the text file. For example, use the "replace value" function to replace the values in the text file
Send me the code and I will change it into a function
Thanks
Nishant
I dont have my laptop with me so cant write the whole code from my mobile. But lets try something
Do the following and send me the code
1. Import the text file in a new query
2. Carry out all the steps in that query to create the logic of replacing the values in the text file. For example, use the "replace value" function to replace the values in the text file
Send me the code and I will change it into a function
Thanks
Nishant