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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
AveragePotato
New Member

Distinct Count of a Column in a Table Without Replacing the Values

Hi,

 

So I've been struggling with designing a visual a particular way. This seems very simple to me, but it's not proving so. Please help!

 

I'm designing a simple, lean report. Everything comes from one table, and all metrics are in a Table visual.

 

I have a column, let's call it vehicle makes, and I need to get a distinct count of the vehicle makes in the total row of the table.

 

Here is what my visual looks like:

 

Vehicle Make         Vehicle Model

Toyota                         Camry

Honda                         Accord

Nissan                         Rogue

Chevrolet                    Silverado

Chevrolet                    Tahoe

Chevrolet                    Impala

 

What I need to do is get a distinct count of the "Vehicle Make" column without changing the values of the Vehicle Make.

 

When I try to do distinct(count) of this column, this is what I get:

 

Vehicle Make         Vehicle Model

1                                  Camry

1                                  Accord

1                                  Rogue

1                                  Silverado

0                                  Tahoe

0                                  Impala

Total 4

 

This is not what I need because the values of the "Vehicle Make" column change to 1s and 0s when I choose to discount(count)

 

My desired result is this:

 

Vehicle Make         Vehicle Model

Toyota                         Camry

Honda                         Accord

Nissan                         Rogue

Chevrolet                    Silverado

Chevrolet                    Tahoe

Chevrolet                    Impala

Total 4

 

I am very frustrated with this and cannot seem to find a working solution. I have tried using measures with VALUES() to achieve this. I have also tried using IF() expression to achieve this, but since there are multiple values to display, I receive the error "a table of multiple values was supplied where a single value was expected."

 

Please help! Thank you!

1 REPLY 1
OwenAuger
Super User
Super User

Hi @AveragePotato 

 

The simplest method I can think of is to write a measure like this:

Vehicle Make or Count = 
IF (
    HASONEVALUE ( 'Table'[Vehicle Make] ), -- This condition may need to be refined
    SELECTEDVALUE ( 'Table'[Vehicle Make] ),
    DISTINCTCOUNT ( 'Table'[Vehicle Make] )
)

and set the number format appropriately, e.g.

"Total "0;;"Total "0

 

This measure will then return a variant type, either text or an integer.

 

Placed in a table visual it would look like this:

OwenAuger_0-1683861733397.png

Note: The condition for whether to display the Vehicle Make value or the DISTINCTCOUNT may need to be refined, but this should work in general.

 

Does this work for you?

(PBIX attached)

 

Regards


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
LinkedIn

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.