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.
Hi guys,
I am new to M Code and I was wondering if anyone could give me a help.
I wrote the code below to connect to a data source and look for the column "ForexExchange". If the column is not found the ERROR should be caught and it should connect to a second data source to extract the information from there.
let get_bidAsk = (file as text) => let Source = Web.Page(Web.Contents(file)), Data3 = Source{3}[Data], #"Changed Type" = Table.TransformColumnTypes(Data3,{{"", type text}, {"ForexExchange", type text}, {"Last", type number}, {"Bid", type number}, {"Ask", type number}, {"Volume", type number}, {"Change %", Percentage.Type}, {"Currency", type text}, {"Time", type time}, {"2", type text}}), TestForError = try Source, Output = if TestForError[HasError] then get_soleBidASK(file) else #"Changed Type" = Table.TransformColumnTypes(Data3,{{"", type text}, {"ForexExchange", type text}, {"Last", type number}, {"Bid", type number}, {"Ask", type number}, {"Volume", type number}, {"Change %", Percentage.Type}, {"Currency", type text}, {"Time", type time}, {"2", type text}}), #"Removed Columns" = Table.RemoveColumns(#"Changed Type",{""}), #"Reordered Columns" = Table.ReorderColumns(#"Removed Columns",{"ForexExchange", "Last", "Bid", "Currency", "Ask", "Volume", "Change %", "Time", "2"}), #"Removed Columns1" = Table.RemoveColumns(#"Reordered Columns",{"2"}) in Output in get_bidAsk
This is print ERROR I get from the function output.
It connects to the first data source and doesnt find the column "ForexExchange". I would need it to identify the ERROR using the try<> and then connect to the second datasource to extract the records there.
Thanks
Hi @Guidera,
I am not specific about Power Query, I personally suggest you post your thread to Power Query forum to get dedicated support. And you can share the solution if you get workaround from the Power Query forum, more people will benefit from here.
Best Regards,
Angelia
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
111 | |
95 | |
80 | |
68 | |
59 |
User | Count |
---|---|
150 | |
119 | |
104 | |
87 | |
67 |