Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Inclue Total in a Table

Hello, 

 

I need make a Line with the total in a table, for example: 

 

I have this table that I insert in power query:

CategoryCount1Count2
A11
B21
C31
D41
E51
F61
G71

 

I need a line in the end of the table, that contains the total and the sum of the colunms, for example:

CategoryCount1Count2
A11
B21
C31
D41
E51
F61
G71
TOTAL287

 

Anybody can help me? 

 

Thanks a lot.

1 ACCEPTED SOLUTION
jgordon11
Resolver II
Resolver II

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUTIE41idaCUnIMsIznMGsozhPBcgywTOcwWyTOE8NyDLDM5zB7LMIbxYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Category = _t, Count1 = _t, Count2 = _t]),
    ChangeType = Table.TransformColumnTypes(Source,{{"Category", type text}, {"Count1", Int64.Type}, {"Count2", Int64.Type}}),
    Total = {"Total", List.Sum(ChangeType[Count1]), List.Sum(ChangeType[Count2])},
    Result = Table.FromRows(Table.ToRows(ChangeType) & {Total}, Table.ColumnNames(ChangeType))
in
    Result

View solution in original post

5 REPLIES 5
ToddChitt
Super User
Super User

Duplicate your original table. Add a Custom Column that is equal to the literal value of "TOTAL". Do a Group By on this custom column and add SUM aggregations for the two columns. Make sure you name the resulting columns exactly the same as the original table.

Now simply UNION (Merge Append) the two tables.

 

Just curious: In the reporting side, you can build a visual table that does all this summing for you with a few mouse clicks. Why do you NEED the TOTAL INSIDE the table as one of the rows of the table?




Did I answer your question? If so, mark my post as a solution. Also consider helping someone else in the forums!

Proud to be a Super User!





Anonymous
Not applicable

Hello @ToddChitt 

 

I need this line with the total for export. 

This export will feed another Power BI.

 

 

OK, but did my suggestion work?

One thing to note: If you have values that come AFTER "T", then they will show up BELOW the TOTAL line and it will look wierd. 




Did I answer your question? If so, mark my post as a solution. Also consider helping someone else in the forums!

Proud to be a Super User!





jgordon11
Resolver II
Resolver II

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUTIE41idaCUnIMsIznMGsozhPBcgywTOcwWyTOE8NyDLDM5zB7LMIbxYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Category = _t, Count1 = _t, Count2 = _t]),
    ChangeType = Table.TransformColumnTypes(Source,{{"Category", type text}, {"Count1", Int64.Type}, {"Count2", Int64.Type}}),
    Total = {"Total", List.Sum(ChangeType[Count1]), List.Sum(ChangeType[Count2])},
    Result = Table.FromRows(Table.ToRows(ChangeType) & {Total}, Table.ColumnNames(ChangeType))
in
    Result
Anonymous
Not applicable

Hello @jgordon11 

 

In power query, where I put this code?

 

tks.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.