let
// Requested company code and exchange code
// Can be taken from the worksheet to easily search for data of other companies
code = "ADEL",
exchange = "TRY",
// Request is based on today's date
today = DateTime.LocalNow(),
years = List.Transform(List.Numbers(-1, 4, -1), each {
Number.Abs(_),
Date.Year(Date.AddQuarters(today, _)),
Date.QuarterOfYear(Date.AddQuarters(today, _)) * 3
}),
// Generating year and period query parameters
period = List.Transform(years, each
"&year" & Text.From(_{0}) & "=" & Text.From(_{1}) &
"&period" & Text.From(_{0}) & "=" & Text.From(_{2})
),
// Web service URL
url = "https://www.isyatirim.com.tr/_layouts/15/IsYatirim.Website/Common/Data.aspx/MaliTablo?companyCode=" & code & "&exchange="
& exchange & "&financialGroup=XI_29"
& Text.Combine(period, "&"),
// Get data and transform it (with year/month column names)
Source = Json.Document(Web.Contents(url)),
value = Source[value],
ConvertToTable = Table.FromList(value, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
ExpandRecords = Table.ExpandRecordColumn(ConvertToTable, "Column1",
{"itemCode", "itemDescTr", "itemDescEng", "value1", "value2", "value3", "value4"},
{"itemCode", "itemDescTr", "itemDescEng"} & List.Transform(years, each Text.From(_{1}) & "/" & Text.From(_{2}))
)
in
ExpandRecords