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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Aaron22
New Member

Power Bi columns

need help 
i have a table = Table1
ColumnA | ColumnB | ColumnC  
Complete    | Complete | Complete 
In Progress  | Complete | Complete |
In Progress   | Complete | In Progress | 

no i need to make another table = Table2, 
Column1 |   countCol   (count the total of complete per column from table 1)
ColumnA |   1
ColumnB |   3
ColumnC |   2

1 ACCEPTED SOLUTION
Vijay_A_Verma
Super User
Super User

See the working here - Open a blank query - Home - Advanced Editor - Remove everything from there and paste the below code to test

 

let
    Query1 = Table1,
    #"Unpivoted Columns" = Table.UnpivotOtherColumns(Query1, {}, "Column1", "Value"),
    #"Filtered Rows" = Table.SelectRows(#"Unpivoted Columns", each ([Value] = "Complete")),
    #"Grouped Rows" = Table.Group(#"Filtered Rows", {"Column1"}, {{"countCol", each Table.RowCount(_), Int64.Type}})
in
    #"Grouped Rows"

 

Another way

let
    Query1 = Table1,
    #"Demoted Headers" = Table.DemoteHeaders(Query1),
    #"Transposed Table" = Table.Transpose(#"Demoted Headers"),
    #"Added Custom" = Table.AddColumn(#"Transposed Table", "countCol", each List.Count(List.Select(Record.ToList(_),each _ = "Complete"))),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Column2", "Column3", "Column4"})
in
    #"Removed Columns"

View solution in original post

1 REPLY 1
Vijay_A_Verma
Super User
Super User

See the working here - Open a blank query - Home - Advanced Editor - Remove everything from there and paste the below code to test

 

let
    Query1 = Table1,
    #"Unpivoted Columns" = Table.UnpivotOtherColumns(Query1, {}, "Column1", "Value"),
    #"Filtered Rows" = Table.SelectRows(#"Unpivoted Columns", each ([Value] = "Complete")),
    #"Grouped Rows" = Table.Group(#"Filtered Rows", {"Column1"}, {{"countCol", each Table.RowCount(_), Int64.Type}})
in
    #"Grouped Rows"

 

Another way

let
    Query1 = Table1,
    #"Demoted Headers" = Table.DemoteHeaders(Query1),
    #"Transposed Table" = Table.Transpose(#"Demoted Headers"),
    #"Added Custom" = Table.AddColumn(#"Transposed Table", "countCol", each List.Count(List.Select(Record.ToList(_),each _ = "Complete"))),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Column2", "Column3", "Column4"})
in
    #"Removed Columns"

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.