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
pasc43
Frequent Visitor

Calculated Column for counting days with gaps

I am trying to make a calculated column that returns the count of days in which Oil was > 0 for each Well ID. Here is some sample data and the Days On column is what I want the calculated column to show. Any help is appreciated. Thanks! 

 

Well IDOn Production DateProduction DateOil Days On
04341-Mar-1724-Feb-170 0
04341-Mar-1725-Feb-170 0
04341-Mar-1726-Feb-170 0
04341-Mar-1727-Feb-170 0
04341-Mar-1728-Feb-170 0
04341-Mar-171-Mar-1763 1
04341-Mar-172-Mar-1735 2
04341-Mar-173-Mar-170 0
04341-Mar-174-Mar-170 0
04341-Mar-175-Mar-178 3
04341-Mar-176-Mar-1714 4
04341-Mar-177-Mar-1747 5
04341-Mar-178-Mar-1747 6
04341-Mar-179-Mar-1754 7
04341-Mar-1710-Mar-1749 8
04341-Mar-1711-Mar-1762 9
04341-Mar-1712-Mar-1731 10
04341-Mar-1713-Mar-1734 11
04341-Mar-1714-Mar-1760 12
04341-Mar-1715-Mar-1749 13
04341-Mar-1716-Mar-170 0
04341-Mar-1717-Mar-170 0
04341-Mar-1718-Mar-1750 14
04341-Mar-1719-Mar-1732 15
08878-Apr-176-Apr-170 0
08878-Apr-177-Apr-170 0
08878-Apr-178-Apr-170 0
08878-Apr-179-Apr-1780 1
08878-Apr-1710-Apr-1778 2
08878-Apr-1711-Apr-1765 3
08878-Apr-1712-Apr-170 0
08878-Apr-1713-Apr-1745 4
08878-Apr-1714-Apr-1735 5
08878-Apr-1715-Apr-1755 6
08878-Apr-1716-Apr-1785 7
08878-Apr-1717-Apr-1770 8
08878-Apr-1718-Apr-170 0
08878-Apr-1719-Apr-170 0
08878-Apr-1720-Apr-170 0
08878-Apr-1721-Apr-170 0
08878-Apr-1722-Apr-170 0
08878-Apr-1723-Apr-170 0
08878-Apr-1724-Apr-1731 9
08878-Apr-1725-Apr-1734 10
1 ACCEPTED SOLUTION
ribisht17
Super User
Super User

@pasc43 

 

Column 4 = if(Oil[Production]=0,0, CALCULATE(COUNT(Oil[Date]),
FILTER(ALLEXCEPT(Oil,Oil[ID]),Oil[Date] <= EARLIER(Oil[Date])),Oil[Production]>0)
)
ribisht17_1-1676119457093.png

 

Mark my post as a solution if it helped you| Munde and Kudis (Ladies and Gentlemen) I like your Kudos!! !!
My YT Channel Dancing With Data !! Connect on Linkedin !! PL 300 Certification Series

View solution in original post

2 REPLIES 2
pasc43
Frequent Visitor

Thank you so much!

ribisht17
Super User
Super User

@pasc43 

 

Column 4 = if(Oil[Production]=0,0, CALCULATE(COUNT(Oil[Date]),
FILTER(ALLEXCEPT(Oil,Oil[ID]),Oil[Date] <= EARLIER(Oil[Date])),Oil[Production]>0)
)
ribisht17_1-1676119457093.png

 

Mark my post as a solution if it helped you| Munde and Kudis (Ladies and Gentlemen) I like your Kudos!! !!
My YT Channel Dancing With Data !! Connect on Linkedin !! PL 300 Certification Series

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.