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

Did you hear? There's a new SQL AI Developer certification (DP-800). Start preparing now and be one of the first to get certified. Register now

Reply
vissvess
Helper V
Helper V

Summarize or aggregate multiple columns

Hi,

 

My data set is like follows.

 

Col 1   Col 2   Col 3 .... .... ....

ABC    ABC    XYZ   ..... .... ....

ABC     DEF   ABC   ..... .... ....

DEF     XYZ    ABC   ..... ..... ....

.....         .....          ......      ..... ..... .....

 

I need this to be summarised as follows.

Agg1         Agg 2      Agg3      ...

ABC(2)     XYZ(1)                     ...

ABC(2)     DEF(1)                     ...

ABC(1)     DEF(1)   XYZ(1)  ...

.....         .....          ......      ..... ..... .....

 

I was trying to achieve this in power query.

Any kind help would be appreciated.

If not possible with power query, DAX support for new column in modelling of power bi would also be appreciated.

 

Thanks in advance.

1 ACCEPTED SOLUTION

@vissvess 

 

I created a small sample file as well with above formula

Please find it attached

 

 

View solution in original post

5 REPLIES 5
Zubair_Muhammad
Community Champion
Community Champion

@vissvess 

 

Try this Custom Column, then split it into new columns

Please see attached file's Query Editor as well

 

=Text.Combine(
Table.AddColumn(
Table.Sort(
Table.Group(Record.ToTable(_),"Value",{{"result",each Table.RowCount(_), type number}}),
{{"Value", Order.Ascending}}),
"Merged",
each [Value] & "(" & Text.From([result])  & ")")[Merged],
", ")

 

Dear @Zubair_Muhammad ,

 

Thanks for the code. The code works well.

 

I need some tweak in it. The code converts all the available column in a table. I need the columns to be specified.

 

Could you please kindly help with it.

 

Thanks

vissvess

Dear @Zubair_Muhammad ,

 

Also, could you give me a suggestion as how to ignore counting if there are null values say out of n columns in a row, if there are 5 empties, the summarization gives me "(5), XXX(2),...." Something like that.

 

Thanks in advance.

 

@vissvess 

 

In this case we can adjust the formula as follows.

You can specify the column names in place of the code in red font below

 

Text.Combine(
Table.AddColumn(
Table.Sort(
Table.Group(
    Table.SelectRows(
    Record.ToTable(
    Record.SelectFields(_,{"Col 1","Col 2","Col 3","Col 4"})
    ),each [Value] <> null and [Value] <> "")
    ,"Value",{{"result",each Table.RowCount(_), type number}}),
{{"Value", Order.Ascending}}),
"Merged",
each [Value] & "(" & Text.From([result])  & ")")[Merged],
", ")

@vissvess 

 

I created a small sample file as well with above formula

Please find it attached

 

 

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

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.