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
Thor46
New Member

Power Query M Problem importing data from Web Site (M Code) - Invoking Function

Hello,

 

 

I wonder if someone could help me 🙂

 

I´m creating an automatic data base that gets data from an public website (financial information):

 

Just to understand what I´m doing

 

This data base contains information about all of the companies (around 140 companies) that trades in both Spanish Stocks Indexes (Mercado Continuo & Ibex 35). In the same URL(link) you can get info from different tables, such as VAT number, Incomes,... 

 

The problem

 

So in order to import the information for each client I´ve created a function, and after that I create a field invoking it to my Data base.

 

 

So when the Function try to obtain this info from a client without the table an error shows up (as we could expect), however it gets stuck in the first client that does not have this table and the query does not continue.

 

 Code used when we Call the Function fnGetNIFDUNS (2 Columns CIF/NIF & D-U-N-S):

 

  Dat_CIF_D = Table.ExpandTableColumn(Table.AddColumn(Add_URLp,"Data", each fnGetNIFDUNS([URLperfil])) ,
     "Data",  {"CIF/NIF", "D-U-N-S"}, {"CIF/NIF", "D-U-N-S"})

 

 

 

What am I looking?

 

Avoid the error for those client without the info (in the web site), either avoiding invoking the function or by creating null values.

 

I´ve already tried with the try & otherwise code but without success.

 

 

Thank you!!

 

 

2 REPLIES 2
Thor46
New Member

Sorry maybe this issues fits better in the Topic: "Integrations with Files and Services".

 

 

try ... otherwise should work. Try the following:

 

  Dat_CIF_D = Table.ExpandTableColumn(Table.AddColumn(Add_URLp,"​Data", each try fnGetNIFDUNS([URLperfil]) otherwise null) ,
     "Data",  {"CIF/NIF", "D-U-N-S"}, {"CIF/NIF", "D-U-N-S"})

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

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.