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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Fabio_B
Frequent Visitor

Create a filter that is the sum of other 3

Hi all, 

I have a database in which the data are like this, to make an easy example:

 

PnPlantRequirement DateRequirement Type

Requirement Quantity

1A1/01/2024Firm10
1A1/01/2024

Raw Material

10
1A1/01/2024Planning10
1A2/01/2024Firm10
1A2/01/2024

Raw Material

10
1A2/01/2024Planning10
1A3/01/2024Firm10
1A3/01/2024

Raw Material

10
1A3/01/2024Planning10

 

I would like to create a new line called "Requirement DOD" with the sum of Plannin, Raw Material and Firm values, to achieve something like this:

 

PnPlantRequirement DateRequirement Type

Requirement Quantity

1A1/01/2024Firm10
1A1/01/2024

Raw Material

10
1A1/01/2024Planning10
1A1/1/2024Requirement DOD

30

1A2/01/2024Firm10
1A2/01/2024

Raw Material

10
1A2/01/2024Planning10
1A2/1/2024Requirement DOD

30

1A3/01/2024Firm10
1A3/01/2024

Raw Material

10
1A3/01/2024Planning10
1A3/1/2024Requirement DOD

30

 

Do someone have an idea on how to achieve this?
Many thanks in advance for all your kind comments.

Best Regards


Fabio

1 ACCEPTED SOLUTION
sevenhills
Super User
Super User

You can try like this in Power Query:

 

Table with Summary Rows

 

let 
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUXIEYkN9A0N9IwMjEyDbLbMoFyRkoBSrg11FUGK5gm9iSWpRZmIOfpUBOYl5eZl56ZiqjAjaaES0jUZE2WhM0EZjom00xm1jLAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Pn = _t, Plant = _t, #"Requirement Date" = _t, #"Requirement Type" = _t, #"Requirement Quantity" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Pn", Int64.Type}, {"Plant", type text}, {"Requirement Date", type date}, {"Requirement Type", type text}, {"Requirement Quantity", Int64.Type}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Pn", "Plant", "Requirement Date"}, {{"Requirement Quantity", each List.Sum([Requirement Quantity]), type nullable number}}),
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Requirement Type", each "Requirement DOD", type text),
    #"Reordered Columns" = Table.ReorderColumns(#"Added Custom",{"Pn", "Plant", "Requirement Date", "Requirement Type", "Requirement Quantity"}),
    #"Appended Query" = Table.Combine({#"Reordered Columns", #"Changed Type"}),
    #"Sorted Rows" = Table.Sort(#"Appended Query",{{"Pn", Order.Ascending}, {"Plant", Order.Ascending}, {"Requirement Date", Order.Ascending}, {"Requirement Type", Order.Ascending}})
in
    #"Sorted Rows"

 

Your data at step #"Changed Type":

sevenhills_0-1713197172382.png

 

Final Ouput:

sevenhills_1-1713197187520.png

 

 

Note: If you want as separate tables, like one as source and other as with summary rows, you can do that too.

Table:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUXIEYkN9A0N9IwMjEyDbLbMoFyRkoBSrg11FUGK5gm9iSWpRZmIOfpUBOYl5eZl56ZiqjAjaaES0jUZE2WhM0EZjom00xm1jLAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Pn = _t, Plant = _t, #"Requirement Date" = _t, #"Requirement Type" = _t, #"Requirement Quantity" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Pn", Int64.Type}, {"Plant", type text}, {"Requirement Date", type date}, {"Requirement Type", type text}, {"Requirement Quantity", Int64.Type}})
in
    #"Changed Type"

sevenhills_2-1713197279578.png

 

 

let
    Source = Table,
    #"Grouped Rows" = Table.Group(Source, {"Pn", "Plant", "Requirement Date"}, {{"Requirement Quantity", each List.Sum([Requirement Quantity]), type nullable number}}),
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Requirement Type", each "Requirement DOD", type text),
    #"Reordered Columns" = Table.ReorderColumns(#"Added Custom",{"Pn", "Plant", "Requirement Date", "Requirement Type", "Requirement Quantity"}),
    #"Appended Query" = Table.Combine({#"Reordered Columns", Table}),
    #"Sorted Rows" = Table.Sort(#"Appended Query",{{"Pn", Order.Ascending}, {"Plant", Order.Ascending}, {"Requirement Date", Order.Ascending}, {"Requirement Type", Order.Ascending}})
in
    #"Sorted Rows"

 

sevenhills_3-1713197293236.png

 

View solution in original post

1 REPLY 1
sevenhills
Super User
Super User

You can try like this in Power Query:

 

Table with Summary Rows

 

let 
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUXIEYkN9A0N9IwMjEyDbLbMoFyRkoBSrg11FUGK5gm9iSWpRZmIOfpUBOYl5eZl56ZiqjAjaaES0jUZE2WhM0EZjom00xm1jLAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Pn = _t, Plant = _t, #"Requirement Date" = _t, #"Requirement Type" = _t, #"Requirement Quantity" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Pn", Int64.Type}, {"Plant", type text}, {"Requirement Date", type date}, {"Requirement Type", type text}, {"Requirement Quantity", Int64.Type}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Pn", "Plant", "Requirement Date"}, {{"Requirement Quantity", each List.Sum([Requirement Quantity]), type nullable number}}),
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Requirement Type", each "Requirement DOD", type text),
    #"Reordered Columns" = Table.ReorderColumns(#"Added Custom",{"Pn", "Plant", "Requirement Date", "Requirement Type", "Requirement Quantity"}),
    #"Appended Query" = Table.Combine({#"Reordered Columns", #"Changed Type"}),
    #"Sorted Rows" = Table.Sort(#"Appended Query",{{"Pn", Order.Ascending}, {"Plant", Order.Ascending}, {"Requirement Date", Order.Ascending}, {"Requirement Type", Order.Ascending}})
in
    #"Sorted Rows"

 

Your data at step #"Changed Type":

sevenhills_0-1713197172382.png

 

Final Ouput:

sevenhills_1-1713197187520.png

 

 

Note: If you want as separate tables, like one as source and other as with summary rows, you can do that too.

Table:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUXIEYkN9A0N9IwMjEyDbLbMoFyRkoBSrg11FUGK5gm9iSWpRZmIOfpUBOYl5eZl56ZiqjAjaaES0jUZE2WhM0EZjom00xm1jLAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Pn = _t, Plant = _t, #"Requirement Date" = _t, #"Requirement Type" = _t, #"Requirement Quantity" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Pn", Int64.Type}, {"Plant", type text}, {"Requirement Date", type date}, {"Requirement Type", type text}, {"Requirement Quantity", Int64.Type}})
in
    #"Changed Type"

sevenhills_2-1713197279578.png

 

 

let
    Source = Table,
    #"Grouped Rows" = Table.Group(Source, {"Pn", "Plant", "Requirement Date"}, {{"Requirement Quantity", each List.Sum([Requirement Quantity]), type nullable number}}),
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Requirement Type", each "Requirement DOD", type text),
    #"Reordered Columns" = Table.ReorderColumns(#"Added Custom",{"Pn", "Plant", "Requirement Date", "Requirement Type", "Requirement Quantity"}),
    #"Appended Query" = Table.Combine({#"Reordered Columns", Table}),
    #"Sorted Rows" = Table.Sort(#"Appended Query",{{"Pn", Order.Ascending}, {"Plant", Order.Ascending}, {"Requirement Date", Order.Ascending}, {"Requirement Type", Order.Ascending}})
in
    #"Sorted Rows"

 

sevenhills_3-1713197293236.png

 

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.