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 August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Sum up the distinct counts with a filter

Hello, 

I have a table that has for each hour if any assets of ours were down.

 

 

I have the following calulation which serves my purposes : 

Hours Down = CALCULATE(DISTINCTCOUNT(Site_Availability_Historyz_Data[Date_Time_History]),Site_Availability_Historyz_Data[AssetPK]<>BLANK())
 
This gives me the all of the hours that were down at a given site regardless if there were 3 rows for a given hour even though 3 assets could have been down, and therefore 3 unique rows for 15:00 hours.
 
However, the total within the table is not summing the distinct counts. I know I need to use a sumx, but I have having trouble with the syntax. Can anyone help? Initally, I tried the following:
 
SUMX(Site_Availability_Historyz_Data,CALCULATE(DISTINCTCOUNT(Site_Availability_Historyz_Data[Date_Time_History]),Site_Availability_Historyz_Data[AssetPK]<>BLANK()))
 
however, certain rows become inaccurate because it is essentially doubling the count of hours when there are two different assets down at a given hour.  
 
Any advice?
1 ACCEPTED SOLUTION

Thank you for providing sample data.  Not sure if this is what you are looking for, but here is a SUMX measure that returns 744 as the result.  Your sample data only has 1 site value.  Does your actual data have multiple Site values?  If so, this measure will calculate the # of down hours for each site and include all in the total.

 

Hours Down =
SUMX (
VALUES ( 'in'[Site] ),
CALCULATE ( DISTINCTCOUNT ( 'in'[Date_Time_History] ) )
)

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

6 REPLIES 6
Anonymous
Not applicable

Still having issues with summarize as its counting duplicates values of column A when column B is different. Would a group by work better?

mahoneypat
Microsoft Employee
Microsoft Employee

Not totally clear but the issue is probably the table in your SUMX.  Please try this pattern in your measure

 

NewMeasure = SUMX(VALUES(Table[Column]), CALCULATE(DISTINCTCOUNT(Site_Availability_Historyz_Data[Date_Time_History]),Site_Availability_Historyz_Data[AssetPK]<>BLANK()))

 

Replace Table[Column] with the one used in your table visual.  If you have more than one column in your visual, you will need to replace the VALUES( ) expression with a SUMMARIZE one.  For example, SUMMARIZE(Table, Table[Column1], Table[Column2]).

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Anonymous
Not applicable

This is my data and how the measure is turning out. 

FatDaddy_0-1597853869558.png

You'll see that the distinct count will get me 744, which is what I want, but the sumx measure to sum is getting me 921. 

 

I'll attatch July's data here https://1drv.ms/u/s!Ag08lU4J4vcXslqhttwvvNGL2vEm?e=R4KRAu 

Thank you for providing sample data.  Not sure if this is what you are looking for, but here is a SUMX measure that returns 744 as the result.  Your sample data only has 1 site value.  Does your actual data have multiple Site values?  If so, this measure will calculate the # of down hours for each site and include all in the total.

 

Hours Down =
SUMX (
VALUES ( 'in'[Site] ),
CALCULATE ( DISTINCTCOUNT ( 'in'[Date_Time_History] ) )
)

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Anonymous
Not applicable

Thank you so much! Can you explain to me why you used sites after values instead of date_Time_history?

Anonymous
Not applicable

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.