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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
Anonymous
Not applicable

Count Completion Item Per Month

I have created a calendar auto table and trying to do a stacked chart to show open vs closed items per month. I could not return the count completed item per month? 

 

CountClosedItemPerMonth =
VAR selectedDate = MAX('Date'[Date])

RETURN

SUMX([Table],
VAR ItemEndDate = [Completion Date]

RETURN IF(ItemEndDate >= selectedDate,1,0)
)
1 ACCEPTED SOLUTION


@Anonymous wrote:

Sorry, I got one problem. it is showing a high value of the blank completion item. How do I resolve it? 


I'm not sure what you mean by "high value" - are you possibly saying you do not want to count rows with no completion date? If so you could just add this condition to the calculate expression.

 

eg.

 

CountClosedItemPerMonth = 
  CALCULATE(countrows(TABLE),
  NOT( ISBLANK( TABLE[Completion Date] ) )
  USERELATIONSHIP(TABLE[Completion Date],'Date'[Date])
)

View solution in original post

5 REPLIES 5
Ashish_Mathur
Super User
Super User

Hi,

Share some data and show the expected result.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
d_gosbell
Super User
Super User

So the expression you have used will count rows that are on or after the last day of the selected period. To count rows with a closed date in the selected month you would normally either create a relationship to the closed date, then you could use a simple countrows expression. Or you could do something like the following pattern

 

CountClosedItemPerMonth =
VAR startOfPeriod = MIN('Date'[Date])
VAR endOfPeriod
 = MAX('Date'[Date])
RETURN
CALCULATE( COUNTROWS('Table'),
    'table'[Completion Date] >= startOfPeriod,
    'table'[Completion Date] <= endOfPeriod
)
Anonymous
Not applicable

Sorry, I got one problem. it is showing a high value of the blank completion item. How do I resolve it? 

I'm using the following formula:

CountClosedItemPerMonth = CALCULATE(countrows(TABLE),USERELATIONSHIP(TABLE[Completion Date],'Date'[Date]))


@Anonymous wrote:

Sorry, I got one problem. it is showing a high value of the blank completion item. How do I resolve it? 


I'm not sure what you mean by "high value" - are you possibly saying you do not want to count rows with no completion date? If so you could just add this condition to the calculate expression.

 

eg.

 

CountClosedItemPerMonth = 
  CALCULATE(countrows(TABLE),
  NOT( ISBLANK( TABLE[Completion Date] ) )
  USERELATIONSHIP(TABLE[Completion Date],'Date'[Date])
)

Anonymous
Not applicable

This is perfect! Exactly what I want. Thank you very much!

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

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