Forum Discussion
Listwise multiplication in power query query
https://1drv.ms/x/c/7b02b2fed748fc63/ETzmzZMX2lJJl7G89fFRfyoBmaLUsZ_cX1TCog6kPPWZ4A Hi
All values in certain columns in the table I obtained from the power query query
I want to multiply a list by period titles.
(inflation table above x all values below)
If there is a way to do this, both in the query and in the pivot table result, I would like you to help me.
| 2024/9 | 2024/6 | 2024/3 | 2023/12 | 2023/9 | 2023/6 | 2023/3 | 2022/12 | 2022/9 | 2022/6 | 2022/3 | 2022/4 | 2022/5 | 2022/52 | 2022/53 | 2022/54 | 2022/55 | 2022/56 | 2022/57 | 2022/58 | 2022/59 | 2022/60 | 2022/61 | 2024/9 | 2024/6 | 2024/3 | 2023/12 | 2023/9 | 2023/6 | 2023/3 | 2022/12 | 2022/9 | 2022/6 | 2022/3 | 2022/4 | 2022/5 | 2022/52 | 2022/53 | 2022/54 | 2022/55 | 2022/56 | 2022/57 | 2022/58 | 2022/59 | 2022/60 | 2022/61 | all to the right | |
| 1,00 | 1,09 | 1,18 | 1,36 | 1,49 | 1,87 | 1,99 | 2,24 | 1,00 | 1,00 | 1,00 | 1,00 | 1,00 | 1,00 | 1,00 | 1,00 | 1,00 | 1,00 | 1,00 | 1,00 | 1,00 | 1,00 | 1,00 | 1,00 | 1,09 | 1,18 | 1,36 | 1,49 | 1,87 | 1,99 | 2,24 | 1,00 | 1,00 | 1,00 | 1,00 | 1,00 | 1,00 | 1,00 | 1,00 | 1,00 | 1,00 | 1,00 | 1,00 | 1,00 | 1,00 | 1,00 | ||
| Sütun Etiketleri | |||||||||||||||||||||||||||||||||||||||||||||||
| 1A | 1AA | 1AB | |||||||||||||||||||||||||||||||||||||||||||||
| Dönen Varlıklar | Nakit ve Nakit Benzerleri | Finansal Yatırımlar | |||||||||||||||||||||||||||||||||||||||||||||
| CURRENT ASSETS | Cash and Cash Equivalents | Short-Term Financial Investments | |||||||||||||||||||||||||||||||||||||||||||||
| Satır Etiketleri | Toplam 2024/9 | Toplam 2024/6 | Toplam 2024/3 | Toplam 2023/12 | Toplam 2023/9 | Toplam 2023/6 | Toplam 2023/3 | Toplam 2022/12 | Toplam 2022/9 | Toplam 2022/6 | Toplam 2022/3 | Toplam 2021/12 | Toplam 2021/9 | Toplam 2021/6 | Toplam 2021/3 | Toplam 2020/12 | Toplam 2020/9 | Toplam 2020/6 | Toplam 2020/3 | Toplam 2019/12 | Toplam 2019/9 | Toplam 2019/6 | Toplam 2019/3 | Toplam 2024/9 | Toplam 2024/6 | Toplam 2024/3 | Toplam 2023/12 | Toplam 2023/9 | Toplam 2023/6 | Toplam 2023/3 | Toplam 2022/12 | Toplam 2022/9 | Toplam 2022/6 | Toplam 2022/3 | Toplam 2021/12 | Toplam 2021/9 | Toplam 2021/6 | Toplam 2021/3 | Toplam 2020/12 | Toplam 2020/9 | Toplam 2020/6 | Toplam 2020/3 | Toplam 2019/12 | Toplam 2019/9 | Toplam 2019/6 | Toplam 2019/3 | Toplam 2024/9 |
| AFYON | 1799446993 | 1297829094 | 1201121800 | 1708271246 | 951541441 | 781204850 | 639730397 | 1160924006 | 677676576 | 459536793 | 317200505 | 196472859 | 154222983 | 134059523 | 146052447 | 136470420 | 107010758 | 95960415 | 71924552 | 66528431 | 58679543 | 72357068 | 76976820 | 817438337 | 342741733 | 371942155 | 460264069 | 166787186 | 130471135 | 75351798 | 452835896 | 234347291 | 103084309 | 86038995 | 18768321 | 462700 | 1309952 | 46662779 | 32350004 | 14850683 | 11456965 | 222118 | 5704011 | 218576 | 907232 | 10679807 | 0 |
| ASTOR | 19384400220 | 15616070284 | 14726371705 | 17708532409 | 9977538488 | 8137413644 | 6869505689 | 8528322665 | 4492612873 | 0 | 0 | 2498897647 | 0 | 1142626133 | 837685327 | 3929684347 | 2910620848 | 1689379079 | 2285825725 | 1234343696 | 1934000187 | 1565859895 | 235805647 | 212890419 | 0 | 0 | 293096282 | 0 | 224697347 | 94004816 | 2780886140 | ||||||||||||||||
| CIMSA | 27922996000 | 13406591000 | 11696077000 | 16420159000 | 7249367000 | 6752445000 | 5949882000 | 14945477000 | 5775581388 | 3986154582 | 2927287116 | 2239831068 | 1986936138 | 1731167885 | 2207271551 | 2556901570 | 1496957273 | 1335612520 | 1710173275 | 1086647670 | 1085041480 | 1097884368 | 985526379 | 19867165000 | 5703081000 | 5060573000 | 8568258000 | 1602597000 | 1910011000 | 2206681000 | 6911575000 | 2002225536 | 646755551 | 372727077 | 257911803 | 440994826 | 565692401 | 355069673 | 903961752 | 417035297 | 415731655 | 756319454 | 267350543 | 239889393 | 176703777 | 144733613 | 0 |
you already have the data in the right format. All you need to do is NOT to do the last step.
Don't do the "PivotedColumns" step, and all will be good. You can then join your table with the inflation table
based on the Period.
6 Replies
- lbendlinSuper User
As usual when you transition from Excel to Power BI, the first thing you need to do is unpivot your data to bring it into a usable format. After that you can decide if you even want to do the calculations in Power Query, or if it is simpler and faster to do them in Power BI.
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WUjDUMzBQUNIBMyyhDEMLKMPYDMowgUlZmEMZlhARIz0jE5h2g4FmxMYCAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"2024/9" = _t, #"2024/6" = _t, #"2024/3" = _t, #"2023/12" = _t, #"2023/9" = _t, #"2023/6" = _t, #"2023/3" = _t, #"2022/12" = _t, #"2022/9" = _t, #"2022/6" = _t, #"2022/3" = _t, #"2021/12" = _t, #"2021/9" = _t, #"2021/6" = _t, #"2021/3" = _t, #"2020/12" = _t, #"2020/9" = _t, #"2020/6" = _t, #"2020/3" = _t, #"2019/12" = _t, #"2019/9" = _t, #"2019/6" = _t, #"2019/3" = _t]), #"Unpivoted Columns" = Table.UnpivotOtherColumns(Source, {}, "Month", "Value"), #"Changed Type" = Table.TransformColumnTypes(#"Unpivoted Columns",{{"Value", type number}}) in #"Changed Type" - AnonymousNot applicable
hi
Thank you for your answer.
I don't use Power BI.Taking it out of the pivot table and reintroducing it into the process would cause me to do a lot of extra work, like a vicious cycle.
It would be better to do this during the power query before the pivot table result.
I think this is what your code does
"
Source = Excel.CurrentWorkbook(){[Name="inflation"]}[Content],
#"PivotColumnsResolved" = Table.UnpivotOtherColumns(Source, {}, "Property", "Value"),
"But the next thing I need help with is:
It is the multiplication of the inflation coefficient under the period by all values corresponding to the same period.let rate = Excel.CurrentWorkbook(){[Name="inflation"]}[Content], // Sembollerin alınması ve filtrelenmesi tblSymbols = Excel.CurrentWorkbook(){[Name="tblSymbols_Sector"]}[Content], RenamedColumns = Table.RenameColumns(tblSymbols, {{"Column1", "Symbol"}}), FilteredSymbols = Table.SelectRows(RenamedColumns, each [Symbol] <> null), // Sütun türlerinin değiştirilmesi ChangedType = Table.TransformColumnTypes(FilteredSymbols, {{"Symbol", type text}}), // Taban URL'lerin eklenmesi ve genişletilmesi BaseURLs = Excel.CurrentWorkbook(){[Name="tblFinansal_URLs"]}[Content], GetBaseURL = Table.AddColumn(ChangedType, "BasedURL", each BaseURLs), ExpandedBasedURL = Table.ExpandTableColumn(GetBaseURL, "BasedURL", {"URL"}, {"URL"}), // Sembollerin URL'ye eklenmesi ve verilerin alınması ReplacedSymbol = Table.AddColumn(ExpandedBasedURL, "ReplaceSYMBOL", each Text.Replace([URL], "SYMBOL", [Symbol])), GetSourceValue = Table.AddColumn(ReplacedSymbol, "GetData", each Table.FromList(Json.Document(Web.Contents([ReplaceSYMBOL]))[value], Splitter.SplitByNothing(), null, null, ExtraValues.Error)), // Verilerin genişletilmesi ExpandedGetData = Table.ExpandTableColumn(GetSourceValue, "GetData", {"Column1"}, {"Column1"}), ExpandedColumn = Table.ExpandRecordColumn(ExpandedGetData, "Column1", {"itemCode", "itemDescTr", "itemDescEng", "value1", "value2", "value3", "value4"}, {"itemCode", "itemDescTr", "itemDescEng", "value1", "value2", "value3", "value4"}), // Seçilen sütunların unpivot edilmesi UnpivotedColumns = Table.Unpivot(ExpandedColumn, {"value1", "value2", "value3", "value4"}, "ValueNo", "Value"), // URL'den dönem bilgisi alınması GetPdFromURL = Table.AddColumn(UnpivotedColumns, "GetPeriodFromURL", each Text.AfterDelimiter([URL], "&year"), type text), SplitColumn = Table.SplitColumn(GetPdFromURL, "GetPeriodFromURL", Splitter.SplitTextByDelimiter("&year", QuoteStyle.None)), // Dönem sütunlarının unpivot edilmesi UnpivotedPeriodColumns = Table.Unpivot(SplitColumn, List.Select(Table.ColumnNames(SplitColumn), each Text.StartsWith(_, "GetPeriodFromURL.")), "Attribute", "TempPd"), // Dönem bilgisine göre özel sütun eklenmesi AddedCustom = Table.AddColumn(UnpivotedPeriodColumns, "Period", each if Text.End([ValueNo], 1) = Text.Start([TempPd], 1) then Text.Replace(Text.End(Text.Start([TempPd], Text.PositionOfAny([TempPd], {"&"}, Occurrence.First)), 4) & "/" & Text.End([TempPd], Text.Length([TempPd]) - Text.PositionOfAny([TempPd], {"="}, Occurrence.Last) - 1), "&", "") else null), // Null değerlerin filtrelenmesi FilteredRows = Table.SelectRows(AddedCustom, each ([Period] <> null) and ([TempPd] <> "")), // Gereksiz sütunların kaldırılması RemovedColumns = Table.RemoveColumns(FilteredRows, {"URL", "ReplaceSYMBOL", "ValueNo", "Attribute", "TempPd"}), // Sütun türlerinin yeniden değiştirilmesi ChangedTypeFinal = Table.TransformColumnTypes(RemovedColumns, {{"Value", Int64.Type}}), // Pivot işlemi PivotedColumn = Table.Pivot(ChangedTypeFinal, List.Distinct(ChangedTypeFinal[Period]), "Period", "Value") in PivotedColumn- lbendlinSuper User
As I said I would unpivot both tables. Then group by Satır Etiketleri , then List.Zip the values with the inflation multiplier.
- AnonymousNot applicable
hi
I couldn't understand how this had anything to do with what I wanted.
I don't use "power bi".
Can this operation be done in "power query"? If so, how.
The sample excel file is there.
Thank you.- lbendlinSuper User
you already have the data in the right format. All you need to do is NOT to do the last step.
Don't do the "PivotedColumns" step, and all will be good. You can then join your table with the inflation table
based on the Period.
- AnonymousNot applicable
The action I want is
It was more complex than that and was in interrogation.
However, I realized that the transaction I wanted could not be solved this way.
Thank you for your answer and efforts.