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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
johndolan2
Resolver I
Resolver I

Distnict count multiple columns

Hi -  am trying to come up with measures to show a distinct total and a percentage of total for the table below labeled "Here is what I have". If you could help that would be great. Thanks, John

 

Here is what I am looking for

ProductCount of Status OnCounr of Status OffStatus On %Status Off %
A1225%75%
B20100%0%
CNANANANA

 

Here is what I have

ProductSevice IDStatus
A14ON
A14ON
A21OFF
A21OFF
A22OFF
B8ON
B9ON
C11Not Applicable
3 ACCEPTED SOLUTIONS
Ashish_Mathur
Super User
Super User

Hi,

For ProductA, the Status on % should be 1/3 i.e. 33.33%.  Am i correct?


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

amitchandak
Super User
Super User

@johndolan2 , % for A does not seems correct, Try like

 

Count of Status On = calculate(distinctcount(Table[Sevice ID]) , filter(Table, Table[Status] = "ON"))
Count of Status Off = calculate(distinctcount(Table[Sevice ID]) , filter(Table, Table[Status] = "OFF"))

Off Status On % = divide([Count of Status On], [Count of Status On] +[Count of Status Off])
Status Off % =divide([Count of Status Off], [Count of Status On] +[Count of Status Off])

or

Off Status On % = divide(calculate(count(Table[Sevice ID]) , filter(Table, Table[Status] = "ON")), count(Table[Sevice ID]))
Status Off % =divide(calculate(distinctcount(Table[Sevice ID]) , filter(Table, Table[Status] = "OFF")) , count(Table[Sevice ID]))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

Hi Amitchandak - Thank you very much!!!

John

View solution in original post

7 REPLIES 7
amitchandak
Super User
Super User

@johndolan2 , % for A does not seems correct, Try like

 

Count of Status On = calculate(distinctcount(Table[Sevice ID]) , filter(Table, Table[Status] = "ON"))
Count of Status Off = calculate(distinctcount(Table[Sevice ID]) , filter(Table, Table[Status] = "OFF"))

Off Status On % = divide([Count of Status On], [Count of Status On] +[Count of Status Off])
Status Off % =divide([Count of Status Off], [Count of Status On] +[Count of Status Off])

or

Off Status On % = divide(calculate(count(Table[Sevice ID]) , filter(Table, Table[Status] = "ON")), count(Table[Sevice ID]))
Status Off % =divide(calculate(distinctcount(Table[Sevice ID]) , filter(Table, Table[Status] = "OFF")) , count(Table[Sevice ID]))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi Amitchandak - Thank you very much!!!

John

Ashish_Mathur
Super User
Super User

Hi,

For ProductA, the Status on % should be 1/3 i.e. 33.33%.  Am i correct?


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi Ashish and Ebeery - to get the % totals I did this: I created a measure to sum the two measures of "distinct count on" with the "distinct count off". I then divided that number against the "distinct count on" and then against the "distinct count off". The %s look good to me. I just want to say thank you! thank you! and thank you! I had been fumbling for hours. 

Hi Ashish Yes, product A should be 1/3 i.e. 33.33%.  .... I was just in the process of fumbling around trying to figure out how to get that number in a measure.  You have been great ... How do I now get that 33.33% in a measure. Thanks, John

I was thinking there was an error in OP's original table - definitely seems like it shouldn't be 25%, but to me it looks like it should be 40% (2/5).

ebeery
Memorable Member
Memorable Member

Hi @johndolan2 

What you're looking for is easily achievable with a Matrix visual.

The measures would look something like this:

DistinctCountOn =
CALCULATE ( DISTINCTCOUNT ( 'Table'[ID] ), 'Table'[Status] = "On" )

DistinctCountOff =
CALCULATE ( DISTINCTCOUNT ( 'Table'[ID] ), 'Table'[Status] = "Off" )


% On =
DIVIDE (
CALCULATE ( COUNT ( 'Table'[ID] ), 'Table'[Status] = "On" ),
COUNT ( 'Table'[ID] )
)

% Off =
DIVIDE(
CALCULATE(
COUNT('Table'[ID]),
'Table'[Status] = "Off"
),
COUNT('Table'[ID])
)

ebeery_0-1609804242586.png

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! It's time to submit your entry.

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 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.