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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

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
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 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.