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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
JBarrett3
Frequent Visitor

Count instances where Aggregated Sum is zero

Hi all,

 

I have table like the below. I need to build a dynamic measure that will indicate if the total pump run hours per site for a given date is zero so that I can count or filter on sites with total zero hours. 

 

Source table:

SiteDatePumpRun_Hours
AAA01/01/201910
BBB01/01/201916
BBB01/01/201920
CCC01/01/201914
DDD01/01/201910
DDD01/01/201920

 

Desired output:

SiteDateZero_Hour_Sites
AAA01/01/20191
BBB01/01/20190
CCC01/01/20190
DDD01/01/20191
Total 2

 

I have found a similar requirement here where the proposed solution was something along the lines of:

 

Measure =
COUNTROWS (
DISTINCT ( CALCULATETABLE ( VALUES ( Table[Site] ), Table[Run Hours] = 0 ) )
)

 

But I am not sure how to enhance this to group by both Site and Date?

 

Many thanks.

 

Jeanette

1 ACCEPTED SOLUTION

@JBarrett3 Ok, please update the Measure logic as below

 

Test308 = 
VAR _Zero = DISTINCT(SELECTCOLUMNS(FILTER(Test308Filter,Test308Filter[Run_Hours]=0),"Site",[Site],"Date",[Date]))
VAR _NonZero = DISTINCT(SELECTCOLUMNS(FILTER(Test308Filter,Test308Filter[Run_Hours]>0),"Site",[Site],"Date",[Date]))
RETURN COUNTROWS(DISTINCT(EXCEPT(_Zero,_NonZero)))+0

image.png





Did I answer your question? Mark my post as a solution!

Proud to be a PBI Community Champion




View solution in original post

3 REPLIES 3
PattemManohar
Community Champion
Community Champion

@JBarrett3  Please try this as New Measure.

 

Test308 = COUNTROWS(DISTINCT(EXCEPT(CALCULATETABLE(VALUES(Test308Filter[Site]),Test308Filter[Run_Hours]=0),CALCULATETABLE(VALUES(Test308Filter[Site]),Test308Filter[Run_Hours]>0))))+0

image.png





Did I answer your question? Mark my post as a solution!

Proud to be a PBI Community Champion




Thank you so much.

That works great for 1 day, but when I introduce a second date the total no longer works. Any idea how to resolve that?

 

image.png

image.png

@JBarrett3 Ok, please update the Measure logic as below

 

Test308 = 
VAR _Zero = DISTINCT(SELECTCOLUMNS(FILTER(Test308Filter,Test308Filter[Run_Hours]=0),"Site",[Site],"Date",[Date]))
VAR _NonZero = DISTINCT(SELECTCOLUMNS(FILTER(Test308Filter,Test308Filter[Run_Hours]>0),"Site",[Site],"Date",[Date]))
RETURN COUNTROWS(DISTINCT(EXCEPT(_Zero,_NonZero)))+0

image.png





Did I answer your question? Mark my post as a solution!

Proud to be a PBI Community Champion




Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

Top Solution Authors
Top Kudoed Authors