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

July 28 - August 9 | Final Round of the Power BI Dataviz World Championships. This is your chance. Learn more

Reply
Anonymous
Not applicable

Transform Multiple Column to Multiple Rows and Count Rows

Hi,

 

I currently have this data:
Capture1.PNG

 

And I wish to have the following results:

Capture2.PNG

 

How can I create this using the "New Table" function? I might also create a new excel sheet with the "Categories". How then can I utilize DAX to Count the rows for multiple columns?

 

Thanks in advanced!

 

Regards,

Nicholas Hiew

1 ACCEPTED SOLUTION
Zubair_Muhammad
Community Champion
Community Champion

@Anonymous

 

Using Power Query/Query Editor would be much more efficient

 

Nevertheless here is a DAX calculated table that might work

 

New Table =
VAR A =
    SUMMARIZECOLUMNS (
        "Category", "A",
        "Count", CALCULATE ( COUNT ( Table1[A] ), Table1[A] = "A" )
    )
VAR B =
    SUMMARIZECOLUMNS (
        "Category", "B",
        "Count", CALCULATE ( COUNT ( Table1[B] ), Table1[B] = "B" )
    )
VAR E =
    SUMMARIZECOLUMNS (
        "Category", "E",
        "Count", CALCULATE ( COUNT ( Table1[E] ), Table1[E] = "E" )
    )
RETURN
    UNION ( A, B, E )

View solution in original post

3 REPLIES 3
Zubair_Muhammad
Community Champion
Community Champion

@Anonymous

 

Using Power Query/Query Editor would be much more efficient

 

Nevertheless here is a DAX calculated table that might work

 

New Table =
VAR A =
    SUMMARIZECOLUMNS (
        "Category", "A",
        "Count", CALCULATE ( COUNT ( Table1[A] ), Table1[A] = "A" )
    )
VAR B =
    SUMMARIZECOLUMNS (
        "Category", "B",
        "Count", CALCULATE ( COUNT ( Table1[B] ), Table1[B] = "B" )
    )
VAR E =
    SUMMARIZECOLUMNS (
        "Category", "E",
        "Count", CALCULATE ( COUNT ( Table1[E] ), Table1[E] = "E" )
    )
RETURN
    UNION ( A, B, E )
Anonymous
Not applicable

Thanks! This works!

I will try the power query solution too.

@Anonymous

 

Using Query Editor

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCijKz0pNLlEwVNJRcgRiJyB2BmIQitVByBtBxGDSLujyxlD9uORNUPWjS5uiagciVxR5M6gehOmo8uYI47HKWyDMx2K7JZLnsTne0ABVAcT4WAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Project = _t, A = _t, B = _t, C = _t, D = _t, E = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Project", type text}, {"A", type text}, {"B", type text}, {"C", type text}, {"D", type text}, {"E", type text}}),
    #"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Project"}, "Attribute", "Value"),
    #"Grouped Rows" = Table.Group(#"Unpivoted Columns", {"Value"}, {{"Count", each Table.RowCount(_), type number}}),
    #"Filtered Rows" = Table.SelectRows(#"Grouped Rows", each ([Value] <> ""))
in
    #"Filtered Rows"

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

Fabric Community Sticker Design Challenge Barcelona Carousel

Fabric Community Sticker Challenge - Barcelona 2026

If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!

July Power BI Update Carousel

Power BI Monthly Update - July 2026

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

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.

Top Solution Authors