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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
bshawbulldog
New Member

Create a column from all distinct values from all columns

I am trying to create a table from all distinct values from all columns and their count. Any help?

1 ACCEPTED SOLUTION

Hi @bshawbulldog,

 

On the query editor select all your columns, then go to Transform - Unpivot

 

You will get a table with two columns Attribute e values.

 

Then on the PBI front do a new table with 

Table = SUMMARIZE(Table; Table[Attribute];Table[Value]; "count" ; COUNT(Table[Value]))

 

 

This will give you distinct for attributes (column name) and Values (data in table) and count of those values

 

Regards,

MFelix

 

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

6 REPLIES 6
Anonymous
Not applicable

Hi @bshawbulldog,

 

Current I haven't found any functions suitable your requirement, maybe you can use below formula to manually summary values:

 

Test =
VAR temp =
    UNION (
        CROSSJOIN (
            ADDCOLUMNS ( { "Column1" }, "Count", COUNTROWS ( VALUES ( Table[Column1] ) ) ),
            VALUES ( Table[Column1] )
        ),
        CROSSJOIN (
            ADDCOLUMNS ( { "Column2" }, "Count", COUNTROWS ( VALUES ( Table[Column2] ) ) ),
            VALUES ( Table[Column2] )
        ),
        CROSSJOIN (
            ADDCOLUMNS ( { "Column3" }, "Count", COUNTROWS ( VALUES ( Table[Column3] ) ) ),
            VALUES ( Table[Column3] )
        )
    )
RETURN
    SELECTCOLUMNS (
        temp,
        "Column Name", [Value],
        "Detail", [Column1],
        "Count", [Count]
    )

Regards,

Xiaoxin Sheng

Hi @Anonymous

The problem here is I might have 100 different columns.

Hi @bshawbulldog,

 

On the query editor select all your columns, then go to Transform - Unpivot

 

You will get a table with two columns Attribute e values.

 

Then on the PBI front do a new table with 

Table = SUMMARIZE(Table; Table[Attribute];Table[Value]; "count" ; COUNT(Table[Value]))

 

 

This will give you distinct for attributes (column name) and Values (data in table) and count of those values

 

Regards,

MFelix

 

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



MFelix
Super User
Super User

Hi  @bshawbulldog,

 

create the table with the following formula:

 

SummaryTable = SUMMARIZE(ALL(Table[Column]); Table[Column]; "count" ; COUNT(Table[Column]))

Should give the expected result.

 

Regards,

Mfelix


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Hi @MFelix

That does not work the way I need it to. I'm looking to have all the distinct values from column 1 ... n in a single column.

Rfranca
Resolver IV
Resolver IV

 

hi, @bshawbulldog

 

Your request for help was very general, give us more details or make the database available to help you.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.