cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Rygar
Helper I
Helper I

Loop through an existing table

Hi all!

 

I think the following task should be solved with some kind of loop:

loop.png

All three Webadresses are stored in Table and the entire example file is here 

The "programming" above works fine but, is there a better way in M to solve this problem then my simple approach above? Some kind of Loop, Recursion or stuff like that?

 

Thanks a lot! Michael

1 ACCEPTED SOLUTION
AlienSx
Memorable Member
Memorable Member

Hello, @Rygar put your names and values into table and ⬇️

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8snMS0lV0lHKKCkpKLbS1y8vL9dLyk8tKk7VS0nVT8wuyUzN0wcr0g3wcdZ1BAnoe7oaGBgEW0YGm5sZKcXqRCs5ZhYp+GQWlmYSNguoVBeqFGqaWxDQNANDIwMDc2OIabmpJanZBA0Cq4KaERpsYGxoCDTFwMBEKTYWAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Name = _t, Value = _t]),
    content = Table.TransformColumns(Source, {"Value", each Web.Page(Web.Contents(_)){1}[Data]{0}[Column2]})
in
    content

View solution in original post

2 REPLIES 2
AlienSx
Memorable Member
Memorable Member

Hello, @Rygar put your names and values into table and ⬇️

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8snMS0lV0lHKKCkpKLbS1y8vL9dLyk8tKk7VS0nVT8wuyUzN0wcr0g3wcdZ1BAnoe7oaGBgEW0YGm5sZKcXqRCs5ZhYp+GQWlmYSNguoVBeqFGqaWxDQNANDIwMDc2OIabmpJanZBA0Cq4KaERpsYGxoCDTFwMBEKTYWAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Name = _t, Value = _t]),
    content = Table.TransformColumns(Source, {"Value", each Web.Page(Web.Contents(_)){1}[Data]{0}[Column2]})
in
    content

Thank you AlienSX, this solution is so elegant and shows its better not to stuck in "loop-thinking"!

For everyone interested, my final solution with an additional column with share-names looks like this:

let
    Source = URL,
    #"Duplizierte Spalte" = Table.DuplicateColumn(Source, "URL", "URL_Value"),
    Values=Table.TransformColumns(#"Duplizierte Spalte", {"URL", each Web.Page(Web.Contents(_)){2}[Caption]}),
    Names=Table.TransformColumns(Values, {"URL_Value", each Web.Page(Web.Contents(_)){1}[Data]{0}[Column2]})
in
    Names

Result as Table

URLURL_Value
Realtime-Kurse Linde PLC Aktie325,95 EUR
Realtime-Kurse Air Liquide Aktie157,73 EUR
Realtime-Kurse Ametek Aktie124,00 EUR

 

Best Michael

Helpful resources

Announcements
PBI Sept Update Carousel

Power BI September 2023 Update

Take a look at the September 2023 Power BI update to learn more.

Learn Live

Learn Live: Event Series

Join Microsoft Reactor and learn from developers.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

MPPC 2023 PBI Carousel

Power Platform Conference-Power BI and Fabric Sessions

Join us Oct 1 - 6 in Las Vegas for the Microsoft Power Platform Conference.

Top Solution Authors
Top Kudoed Authors