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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
Anonymous
Not applicable

Count the number of occurrences of a particular date

I have a dataset with three columns: department, date (with the latest filter applied), and work order number. For each department, I am trying to calculate the number of work orders that have the date listed in the table. 

bz0719_0-1641830755926.png

I applied a department filter here for simplicity. An example of an expected result would be for the date of Monday, December 20, the measure or column would show a value of 2 since there are two work orders listed on that date. I would like the number of occurrences for each latest date for each department. 

 

Any help here would be appreciated.  

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , Try a measure like

 

Measure =
VAR __id = MAX ('Table'[department] )
VAR __date = CALCULATE ( MAX('Table'[Date] ), ALLSELECTED ('Table' ), 'Table'[department] = __id )
CALCULATE ( distinctcount ('Table'[WorkOrd] ), VALUES ('Table'[department] ),'Table'[department] = __id,'Table'[Date] = __date )

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

5 REPLIES 5
v-easonf-msft
Community Support
Community Support

Hi, @Anonymous 

Could you please tell me whether your problem has been solved?

If yes, you could accept the helpful answer as solution. You could also share your own solution here.It will help other community members easily find the solution when they get the similar issue.

 

Best Regards,
Community Support Team _ Eason

YukiK
Impactful Individual
Impactful Individual

You can use a measure like:

Your Measure =
CALCULATE( 
    COUNT( 'Table'[WorkOrd] ),
    ALLSELECTED('Table'[WorkOrd])
)
amitchandak
Super User
Super User

@Anonymous , Try a measure like

 

Measure =
VAR __id = MAX ('Table'[department] )
VAR __date = CALCULATE ( MAX('Table'[Date] ), ALLSELECTED ('Table' ), 'Table'[department] = __id )
CALCULATE ( distinctcount ('Table'[WorkOrd] ), VALUES ('Table'[department] ),'Table'[department] = __id,'Table'[Date] = __date )

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Hi, 

 

Thank you for your prompt reply. I have tried inserting the measure based on your feedback above and it is throwing this error: 

bz0719_0-1641833058835.png

I am fairly new to DAX/measure syntax so any help is appreciated. 

YukiK
Impactful Individual
Impactful Individual

You'd need "RETURN" before calculate function!

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

Top Solution Authors
Top Kudoed Authors