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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
ccjj
Helper I
Helper I

Sum of distinct values - New Column

Hi Community, 

 

I have a dataset with the following table.  I am trying to create a new column based on Count of distinct "Company" and distinct "Services" (divided by total services of 10).  I found a way to do this as a Measure, but can't seem to get it to work as a Column.  Any thoughts/help is appreciated.

 

ccjj_0-1650320489525.png

 

1 ACCEPTED SOLUTION

Now it's solved 🙂

 

Try this code:

Column = 
VAR _A =
    CALCULATE (
        DISTINCTCOUNT ( 'Table'[Services] ),
        ALLEXCEPT ( 'Table', 'Table'[Company] )
    )
RETURN
_A/10

 

And set the column format as a Percentage, output:

VahidDM_1-1650328143983.png

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

 

 

 

View solution in original post

6 REPLIES 6
VahidDM
Super User
Super User

Hi @ccjj 

 

Try this code to add a new Column:

Column = 
VAR _A =
    CALCULATE (
        DISTINCTCOUNT ( 'Table'[Services] ),
        ALLEXCEPT ( 'Table', 'Table'[Company] )
    )
RETURN
    ( 10 / _A ) / 100

 

Output:

 

VahidDM_0-1650326284337.png

 

 

Download the sample file (Attached).

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

Thank you!  

The first 3 shows is showing 3.33% when it should show 33%. Any way to adjust that?

@ccjj 

 

Can you please add more details how did you calculate 33% and 10%?

 


Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

"Company1" has 3 distinct services, so the calculation is 3/10 = 30% (sorry I did the math wrong :))

"Company2" has 2 services but only only 1 distinct, so the calculation is 1/10 = 10%

 

Now it's solved 🙂

 

Try this code:

Column = 
VAR _A =
    CALCULATE (
        DISTINCTCOUNT ( 'Table'[Services] ),
        ALLEXCEPT ( 'Table', 'Table'[Company] )
    )
RETURN
_A/10

 

And set the column format as a Percentage, output:

VahidDM_1-1650328143983.png

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

 

 

 

that worked perfectly...THANK YOU!!!

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors