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
Learner_SG
Helper IV
Helper IV

Sum of Distinct values

Hi all,

I am trying to get the sum of the occupancy of these fields. But I need to get the distinct value sums only. How to add it in the measures.Could anyone help.

Learner_SG_0-1650352739476.png

 

 

Male_toilet_occupancy_count =
CALCULATE (SUM( measurement[IOT status]),
FILTER ( 'measurement',measurement[Is IN 30Minutes]=1 && measurement[object.Document.objects.name] in{ "WC Glass Flush Valve M_01","WC Glass Flush Valve M_02","WC Glass Flush Valve M_03","WC Glass Flush Valve M_04","WC Glass Flush Valve M_05","Urinal Glass Flush Valve M_01","Urinal Glass Flush Valve M_02","Urinal Glass Flush Valve M_03","Urinal Glass Flush Valve M_04","Urinal Glass Flush Valve M_05","Urinal Glass Flush Valve M_06","Urinal Glass Flush Valve M_07"}))+0
1 ACCEPTED SOLUTION

Alright!  I would suggest to have less hardcoded values so I have created a separate table containing the list of Male toilets and created a measure which will compare the values one by one and if it is a male toilet, will add to the distinct count(I have taken distinct count as the IOT status for all of them is 1. I have taken it into account as a filter.

 

Here is the Dax code for measure:

Output:

PC2790_0-1650441583184.png

and the table containing list of male toilets looks like:

PC2790_1-1650441661599.png

 

View solution in original post

7 REPLIES 7
Learner_SG
Helper IV
Helper IV

@PC2790  thanks,it worked.

PC2790
Community Champion
Community Champion

You canmake use of SUMX and distinct i like:

SUMX(DISTINCT(measurement[IOT status]),measurement[IOT status])

amitchandak
Super User
Super User

@Learner_SG m Try like

 

CALCULATE (SUMX(summarize(measurement, measurement[IOT status]), [IOT status]),
FILTER ( 'measurement',measurement[Is IN 30Minutes]=1 && measurement[object.Document.objects.name] in{ "WC Glass Flush Valve M_01","WC Glass Flush Valve M_02","WC Glass Flush Valve M_03","WC Glass Flush Valve M_04","WC Glass Flush Valve M_05","Urinal Glass Flush Valve M_01","Urinal Glass Flush Valve M_02","Urinal Glass Flush Valve M_03","Urinal Glass Flush Valve M_04","Urinal Glass Flush Valve M_05","Urinal Glass Flush Valve M_06","Urinal Glass Flush Valve M_07"}))+0

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

@amitchandak @PC2790  both options are not giving me the correct answer. Its the measurement[object.Document.objects.name which will be occuring more than once, so is the distinct/summarize to be placed there? 

Can you provide your sample data please? It'll be easier to give the solution and also try:

SUMX( Distinct(measurement[object.Document.objects.name]),Calculate(Sum(measurement, measurement[IOT status]),FILTER ( 'measurement',measurement[Is IN 30Minutes]=1))

@PC2790  I have extracted the 3 tables sample data and pasted it below. Basically, my condition is that when Is in 30 minutes column is 1 and I need to sum up all the male toilets occupied which is known by the IOT status as 1.  for the example stated above , it sums up all the male toilets denoted by the names in it . but what happens is that , it does not distincts out  and I get duplicated counts.below is the data

object.Document.objects.nameIs IN 30MinutesIOT status
WC Glass Flush Valve F_0511
WC Glass Flush Valve M_0411
WC Glass Flush Valve HCP_0111
WC Glass Flush Valve M_0311
WC Glass Flush Valve F_0511
WC Glass Flush Valve F_0511
WC Glass Flush Valve F_0511
WC Glass Flush Valve F_1611
WC Glass Flush Valve F_1611
WC Glass Flush Valve F_1611
WC Glass Flush Valve F_1011
WC Glass Flush Valve F_0511
Deck Mounted Sensor Tap F_0211
Deck Mounted Sensor Tap F_0211
Deck Mounted Sensor Tap M_0411
Deck Mounted Sensor Tap M_0311
Deck Mounted Sensor Tap M_0311
Deck Mounted Sensor Tap F_0911
Deck Mounted Sensor Tap F_0911
Deck Mounted Sensor Tap F_0911
Deck Mounted Sensor Tap M_0211
Deck Mounted Sensor Tap M_0211
Deck Mounted Sensor Tap M_0511
Deck Mounted Sensor Tap M_0511
Deck Mounted Sensor Tap F_0211
Deck Mounted Sensor Tap F_0211
Deck Mounted Sensor Tap F_0211
Deck Mounted Sensor Tap F_0211
Deck Mounted Sensor Tap F_0211

 from this if i need to count the male toilets occupied , i need to distinctly count them fyi these are the male toilet/urinal names "WC Glass Flush Valve M_01","WC Glass Flush Valve M_02","WC Glass Flush Valve M_03","WC Glass Flush Valve M_04","WC Glass Flush Valve M_05","Urinal Glass Flush Valve M_01","Urinal Glass Flush Valve M_02","Urinal Glass Flush Valve M_03","Urinal Glass Flush Valve M_04","Urinal Glass Flush Valve M_05","Urinal Glass Flush Valve M_06","Urinal Glass Flush Valve M_07. 

 

for this case   there are only 2 male toilet occupied (distinct)and for female also it should be 4 ,

hope my question is clear. thanks for the help.

Alright!  I would suggest to have less hardcoded values so I have created a separate table containing the list of Male toilets and created a measure which will compare the values one by one and if it is a male toilet, will add to the distinct count(I have taken distinct count as the IOT status for all of them is 1. I have taken it into account as a filter.

 

Here is the Dax code for measure:

Output:

PC2790_0-1650441583184.png

and the table containing list of male toilets looks like:

PC2790_1-1650441661599.png

 

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