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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
raywoc
New Member

Conditional Expression to Sum True Values Across Many Columns

Greetings Hive Mind - I have a large data set with around 200 columns, many of which have pairs of groupings.  In PowerQuery, I am trying to have  a conditional function, where if true, will sum only those values from the true columns.

 

sample table.png

 

Above is a sample.  I essentially want the measure to pick up and sum the "Reported" value of each "Reported" column, where the condition is met that Reported > 0 and Validated = 0. 

 

So in the example above, the New Measure would be 200, summed from the Reported 1 and Reported 2 columns for Audit 1 and Report 2 and Reported 3 for Audit 2.

 

Thanks in advanced for all the help this forum provides! 

1 ACCEPTED SOLUTION
samdthompson
Memorable Member
Memorable Member

Hello, try this. (obvioulsy the source etc might need to change but it just makes the data tall rather than wide, adds some logic and away you sgo with a simple SUM once you get to the DAX side)

 

let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Unpivoted Other Columns" = Table.UnpivotOtherColumns(Source, {"Audit"}, "Attribute", "Value"),
#"Split Column by Delimiter" = Table.SplitColumn(#"Unpivoted Other Columns", "Attribute", Splitter.SplitTextByDelimiter(" ", QuoteStyle.Csv), {"Attribute.1", "Attribute.2"}),
#"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Attribute.1", type text}, {"Attribute.2", Int64.Type}}),
#"Pivoted Column" = Table.Pivot(#"Changed Type1", List.Distinct(#"Changed Type1"[Attribute.1]), "Attribute.1", "Value"),
#"Added Custom" = Table.AddColumn(#"Pivoted Column", "ValueToSum", each if [Reported]>0 and [Validated]=0 then [Reported] else 0)
in
#"Added Custom"

 

 

cheers

// if this is a solution please mark as such. Kudos always appreciated.

View solution in original post

4 REPLIES 4
wdx223_Daniel
Community Champion
Community Champion

=Table.AddColumn(PreviousStepName,"Custom",each List.Sum(List.Zip(List.Select(List.Split(List.Skip(Record.ToList(_)),2),each _{1}=0)){0}))

@wdx223_Daniel , how do you find the performance impact of using List.Zip across 200 odd columns? I ve never used it for more than 20 odd but I found the impact pretty sizable so have shied away from it. That may have been my data of course. 

 

// if this is a solution please mark as such. Kudos always appreciated.

just provide a solution for the samle data, the efficiency is not always in my concern.

samdthompson
Memorable Member
Memorable Member

Hello, try this. (obvioulsy the source etc might need to change but it just makes the data tall rather than wide, adds some logic and away you sgo with a simple SUM once you get to the DAX side)

 

let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Unpivoted Other Columns" = Table.UnpivotOtherColumns(Source, {"Audit"}, "Attribute", "Value"),
#"Split Column by Delimiter" = Table.SplitColumn(#"Unpivoted Other Columns", "Attribute", Splitter.SplitTextByDelimiter(" ", QuoteStyle.Csv), {"Attribute.1", "Attribute.2"}),
#"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Attribute.1", type text}, {"Attribute.2", Int64.Type}}),
#"Pivoted Column" = Table.Pivot(#"Changed Type1", List.Distinct(#"Changed Type1"[Attribute.1]), "Attribute.1", "Value"),
#"Added Custom" = Table.AddColumn(#"Pivoted Column", "ValueToSum", each if [Reported]>0 and [Validated]=0 then [Reported] else 0)
in
#"Added Custom"

 

 

cheers

// if this is a solution please mark as such. Kudos always appreciated.

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.