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
OscarSuarez10
Helper III
Helper III

Total production pero job and year

Hello 

I have the follwing table in the Query Editor:

JOBITEMYEARPRODUCTION
0A1100
0A2300
0B1200
0B2500
1A1450
1A278
1B1150
1B232
2A146
2A279
2B142
2B212

 

And I need to get the total production pero Jon and Year like this:

 

JOBYEARPRODUCTION
01300
02800
11600
12110
2188
2291

 

Can you help me ?

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

Hi @OscarSuarez10 ,

 

Here we can group by the JOB and Year column in power query to get the excepted result.

 

Capture.PNG

 

M code for your reference :

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("XcxLDsAgCEXRvTB2AKj9DNttGPe/DcGIhQ4IycnLbQ0QEjxypIcIPX3GctnZu3b8M93VZeR6pUbT3Xltshy5meUyT2JfOwLN2L3JYoUD6SehPgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [JOB = _t, ITEM = _t, YEAR = _t, PRODUCTION = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"JOB", Int64.Type}, {"ITEM", type text}, {"YEAR", Int64.Type}, {"PRODUCTION", Int64.Type}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"JOB", "YEAR"}, {{"Sum", each List.Sum([PRODUCTION]), type number}})
in
    #"Grouped Rows"
Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

2 REPLIES 2
v-frfei-msft
Community Support
Community Support

Hi @OscarSuarez10 ,

 

Here we can group by the JOB and Year column in power query to get the excepted result.

 

Capture.PNG

 

M code for your reference :

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("XcxLDsAgCEXRvTB2AKj9DNttGPe/DcGIhQ4IycnLbQ0QEjxypIcIPX3GctnZu3b8M93VZeR6pUbT3Xltshy5meUyT2JfOwLN2L3JYoUD6SehPgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [JOB = _t, ITEM = _t, YEAR = _t, PRODUCTION = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"JOB", Int64.Type}, {"ITEM", type text}, {"YEAR", Int64.Type}, {"PRODUCTION", Int64.Type}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"JOB", "YEAR"}, {{"Sum", each List.Sum([PRODUCTION]), type number}})
in
    #"Grouped Rows"
Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

Thank you, If I have another production column (PRODUCTION2), how can I add it to do the same thing? I am trying to do this: #"Grouped Rows" = Table.Group(#"Changed Type", {"JOB", "Year"}, {{"Sum", each List.Sum([PRODUCTION),type number}}, {{"Sum2", each List.Sum([PRODUCTION2]),type number}}) But it didn´t worked

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