Kommentare zu: 3 ways for sums over columns in Power Query https://ssbi-blog.de/blog/technical-topics-english/3-ways-for-sums-over-columns-in-power-query/ Wir lieben Microsoft Power BI Thu, 10 Apr 2025 11:43:23 +0000 hourly 1 https://wordpress.org/?v=6.8.2 Von: Mahmoud Bani Asadi https://ssbi-blog.de/blog/technical-topics-english/3-ways-for-sums-over-columns-in-power-query/#comment-5855 Fri, 13 Sep 2024 23:05:00 +0000 https://ssbi-blog.de/?p=9315#comment-5855 This is an excellent topic! Here’s my custom function designed to achieve something similar.

= (tbl as table) =>
let
_type = Table.TransformColumnTypes(tbl,Table.ToRows(Table.ReplaceValue(Table.Distinct(Table.UnpivotOtherColumns(tbl, {}, „Attribute“, „Value“), {„Attribute“}),each [Value],each Value.Type([Value]),Replacer.ReplaceValue,{„Value“}))),
total = _type & Table.PromoteHeaders(Table.Transpose(Table.ReplaceValue(Table.SelectColumns(Table.AddColumn(Table.Profile(_type), „Sum“, each [Average] * [Count], type number),{„Column“, „Sum“}),
each [Sum],each if [Column]=Table.ColumnNames(_type){0} then „Total“ else [Sum],Replacer.ReplaceValue,{„Sum“})), [PromoteAllScalars=true])
in
total

]]>
Von: sandeep pawar https://ssbi-blog.de/blog/technical-topics-english/3-ways-for-sums-over-columns-in-power-query/#comment-1115 Mon, 06 Jul 2020 20:53:13 +0000 https://ssbi-blog.de/?p=9315#comment-1115 Lars, I dont see the solutions in the blog. I just see below. Do I need to download a file?
Solution #1 – by Bill Szysz

Solution #2 – by Bill Szysz

Solution #3 – by Imke Feldmann

]]>
Von: mma173 https://ssbi-blog.de/blog/technical-topics-english/3-ways-for-sums-over-columns-in-power-query/#comment-1071 Fri, 12 Jun 2020 12:16:40 +0000 https://ssbi-blog.de/?p=9315#comment-1071 Thanks‘ for sharing this. There was lots to learn from the solutions provided by the very well recognized PQ gurus. It was a very good exercise too.

Here is the solution that I came-up with:
let
Source = Excel.CurrentWorkbook(){[Name=“Datenbasis“]}[Content],
ToSum = {„January“,“February“, „March“, „April“, „May“, „June“, „July“, „August“, „September“, „October“, „November“, „December“},
Sums = List.Transform (Table.ColumnNames(Source), each if _=“Cost centre“ then „Total“ else if List.Contains(ToSum,_) then try List.Sum(Table.Column(Source, _)) otherwise _ else null),
SumTable = Table.PromoteHeaders(Table.Transpose(Table.FromColumns({Table.ColumnNames(Source), Sums}))),
Combine = Table.Combine({Source,SumTable})
in
Combine

]]>