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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Calculate columns in a new table based on multiple tables

Hello everyone,

 

I have a problem and don't know how to proceed.

 

I have several tables. For each table (table 1 and 2) I would like to count the number of distinct values in column "Value":

 

Table1 --> Number of distinct values = 2

IDValue
1xyz
5xyz
12abc

 

Table 2 --> Number of distinct values = 3

IDValue
2abc
4def
10ghi

 

Based on this I would like to create a new table containing a list of the number of the distinct values for each table:

 

New table

TableNumber of distinct values
Table 12
Table 23

 

I hope someone can help. Thanks in advance!

1 ACCEPTED SOLUTION
VahidDM
Super User
Super User

Hi @Anonymous 

Try this code to create a new table:

 

 

 

Count Table =
UNION (
    SUMMARIZE (
        'Table 1',
        "Table", "Table 1",
        "Number of distinct values", DISTINCTCOUNT ( 'Table 1'[Value] )
    ),
    SUMMARIZE (
        'Table 2',
        "Table", "Table 2",
        "Number of distinct values", DISTINCTCOUNT ( 'Table 2'[Value] )
    )
)

 

 

Output:

VahidDM_0-1630310679837.png

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Appreciate your Kudos VahidDM_1-1630310689722.png !!

 

View solution in original post

1 REPLY 1
VahidDM
Super User
Super User

Hi @Anonymous 

Try this code to create a new table:

 

 

 

Count Table =
UNION (
    SUMMARIZE (
        'Table 1',
        "Table", "Table 1",
        "Number of distinct values", DISTINCTCOUNT ( 'Table 1'[Value] )
    ),
    SUMMARIZE (
        'Table 2',
        "Table", "Table 2",
        "Number of distinct values", DISTINCTCOUNT ( 'Table 2'[Value] )
    )
)

 

 

Output:

VahidDM_0-1630310679837.png

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Appreciate your Kudos VahidDM_1-1630310689722.png !!

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.