Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Expression error

Hi

Need some quick help pl as new here. Am getting similar error. 

Learning to replicate as in https://www.youtube.com/watch?v=STjBoS1rQuQ&list=LL&index=11&t=311s 

Pl do redirect to a tutorial if any

Reached half way to create fx in pbi:

= (URL) as table =>
let
Source = Web.Page(Web.Contents([URL]))
in
#"fxMovies"

 

and 

let
Source = Excel.Workbook(File.Contents("C:\Users\ssh130\OneDrive\pbi\linked.xlsx"), null, true),
Sheet1_Sheet = Source{[Item="Sheet1",Kind="Sheet"]}[Data],
#"Changed Type" = Table.TransformColumnTypes(Sheet1_Sheet,{{"Column1", type text}}),
#"Renamed Column

1 ACCEPTED SOLUTION

Hi @Anonymous 

 

Unfortunately Power Query doesn't have the ability to interact with web pages by doing things like clicking buttons.

 

But, if you click MORE it loads this page

 

https://www.moneycontrol.com/stocks/marketstats/bse-gainer/all-companies_-1/more/

 

So you could include that in your list of URL's and it will fetch that page's data.

 

Regards

 

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


View solution in original post

8 REPLIES 8
PhilipTreacy
Super User
Super User

Hi @Anonymous 

 

In addition to changing your function code as I said

(URL as text) =>
let
    Source = Web.Page(Web.Contents(URL))
in
    Source 

 

You need to change the code that calls the function.  It should be this

fxMovies([URL])

 

You need () around the [URL]

 

Regards

 

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Anonymous
Not applicable

Thanks Phil

Appreciate the learning support!

 

Do we have a course to refer to else have to keep asking here.

I have 1 hopefully last ques as query is not executing. Am also not sure if there is another way to input a list except upload an excel file which somehow is failing to connect through One drive.

---------------------

let

    Source = Excel.Workbook(File.Contents("C:\Users\ssh130\OneDrive\pbi\linked.xlsx"), null, true),

    Sheet1_Sheet = Source{[Item="Sheet1",Kind="Sheet"]}[Data],

    #"Changed Type" = Table.TransformColumnTypes(Sheet1_Sheet,{{"Column1", type text}}),

    #"Renamed Columns" = Table.RenameColumns(#"Changed Type",{{"Column1", "URL"}}),

    #"Added Custom" = Table.AddColumn(#"Renamed Columns", "fetch", each fxMovies([URL])),

    #"Expanded fetch" = Table.ExpandTableColumn(#"Added Custom", "fetch", {"Data"}, {"fetch.Data"}),

    #"Expanded fetch.Data" = Table.ExpandTableColumn(#"Expanded fetch", "fetch.Data", {"Company Name.....

 

Best Rgds

Saurabh

Hi @Anonymous 

 

How exactly is it not executing?  Is it not loading the list of URL's from the Excel workbook?

 

There are other ways to enter lists.  If the list isn't very long.

 

In PBI Desktop you can try clicking on Enter data

ed1.png

 

Which gives ytou this window where you can type in the list of URL's, name the column and name the table

ed2.png

 

Clicking on OK will then create a table in Power Query.

ed3.png

 

This can be loaded into your main query in the Source step like this, followed by the other steps.  Note you don't need the Changed Type and Renamed Columns steps in this scenario.

 

let
    Source = URLTable,

    #"Added Custom" = Table.AddColumn(#"Renamed Columns", "fetch", each fxMovies([URL])),

    #"Expanded fetch" = Table.ExpandTableColumn(#"Added Custom", "fetch", {"Data"}, {"fetch.Data"}),

    #"Expanded fetch.Data" = Table.ExpandTableColumn(#"Expanded fetch", "fetch.Data", {"Company Name.....

 

 

In terms of Power Query courses there are a several you can choose between, here's a couple you could check out

 

https://www.myonlinetraininghub.com/excel-power-query-course

Power Query Academy - Skillwave Training

 

Regards

 

Phil

 



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Anonymous
Not applicable

Thanks. Yes it does not load from excel, tried csv as well. Is there are a way to keep the list dynamic and link to another file?

 

Hi @Anonymous 

 

Loading from an Excel file or a CSV should work.  What exactly is the error message you are getting?

 

Can you upload (either here or to OneDrive, Google Drive or DropBox) your Excel workbook or CSV to test?

 

Regards

 

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Anonymous
Not applicable

Thanks. It worked as txt (notepad) so sorted 🙂

Only issue I see is I get partial data. Is there a way to bypass the 'more' button to fetch all data?

Hi @Anonymous 

 

Unfortunately Power Query doesn't have the ability to interact with web pages by doing things like clicking buttons.

 

But, if you click MORE it loads this page

 

https://www.moneycontrol.com/stocks/marketstats/bse-gainer/all-companies_-1/more/

 

So you could include that in your list of URL's and it will fetch that page's data.

 

Regards

 

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


PhilipTreacy
Super User
Super User

Hi @Anonymous 

 

Change your function code to this

(URL as text) =>
let
    Source = Web.Page(Web.Contents(URL))
in
    Source 

 

Regards

 

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.