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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
magikan01
New Member

Adding total to the yearly revenues

Hi everyone!

 

So, I'm new to Power BI - literally one week into my course, and already am feeling it. Anyway, can any of you help me out on this please? 

 

I have a table of total revenues from Excel, picture below:

 

magikan01_0-1707851009819.png

 

Problem is I've been having trouble with putting the Total Revenues column inside the Power query editor. 

 

magikan01_1-1707851089646.png

 

I tried grouping the years to get a sum total, and so far it just gives me errors. 

 

I feel stuck. Any tips?

 

Much appreciated. 

 

1 ACCEPTED SOLUTION
v-xinruzhu-msft
Community Support
Community Support

Hi @magikan01 

1.The better way is to use the marix visual or table visual it will generate the total, e.g use matrix visual.

put the following field to matrix

vxinruzhumsft_0-1709107482169.png

Output

vxinruzhumsft_1-1709107499684.png

 

2.You can add three custom columns to calculate the year total, you can put the following code to advanced editor in power query

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("NZDNagMxDITfxecc9GNZ0nGbbAOhTULbFMqS93+NSvIGDB78jcZjb1u7LNd2aLFQRmcIQTBQoD0PW3tf316QhXvCjs5e8HP5mpDdSShEH0NpFFzuCdEGuKclULe0ICvhPv9XM0aOIWKf94uowbz/8shyAuyYw6KoTHUytOtu+cgUBuyT+IyToSwyuzzO1dJcOAlFzSwlPCji0vK93tMCYq4pzNCg6qLtltvxp1KUbSSheJlOATK7XG+/9dbe51951OXKJaBpOa3HJMxMSQhVSEo4a1ie/w==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Month = _t, #"2021" = _t, #"2022" = _t, #"2023" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Month", type text}, {"2021", Int64.Type}, {"2022", Int64.Type}, {"2023", Int64.Type}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Sum_2021", each List.Sum(#"Changed Type"[2021])),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "Sum_2022", each List.Sum(#"Changed Type"[2022])),
    #"Added Custom2" = Table.AddColumn(#"Added Custom1", "Sum_2023", each List.Sum(#"Changed Type"[2023]))
in
    #"Added Custom2"

 

Output

vxinruzhumsft_0-1707875317782.png

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

View solution in original post

2 REPLIES 2
v-xinruzhu-msft
Community Support
Community Support

Hi @magikan01 

1.The better way is to use the marix visual or table visual it will generate the total, e.g use matrix visual.

put the following field to matrix

vxinruzhumsft_0-1709107482169.png

Output

vxinruzhumsft_1-1709107499684.png

 

2.You can add three custom columns to calculate the year total, you can put the following code to advanced editor in power query

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("NZDNagMxDITfxecc9GNZ0nGbbAOhTULbFMqS93+NSvIGDB78jcZjb1u7LNd2aLFQRmcIQTBQoD0PW3tf316QhXvCjs5e8HP5mpDdSShEH0NpFFzuCdEGuKclULe0ICvhPv9XM0aOIWKf94uowbz/8shyAuyYw6KoTHUytOtu+cgUBuyT+IyToSwyuzzO1dJcOAlFzSwlPCji0vK93tMCYq4pzNCg6qLtltvxp1KUbSSheJlOATK7XG+/9dbe51951OXKJaBpOa3HJMxMSQhVSEo4a1ie/w==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Month = _t, #"2021" = _t, #"2022" = _t, #"2023" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Month", type text}, {"2021", Int64.Type}, {"2022", Int64.Type}, {"2023", Int64.Type}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Sum_2021", each List.Sum(#"Changed Type"[2021])),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "Sum_2022", each List.Sum(#"Changed Type"[2022])),
    #"Added Custom2" = Table.AddColumn(#"Added Custom1", "Sum_2023", each List.Sum(#"Changed Type"[2023]))
in
    #"Added Custom2"

 

Output

vxinruzhumsft_0-1707875317782.png

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

magikan01
New Member

forgot to mention, I did deselect the total in the month part, just wanted to show it for the question purposes.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors