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 September 15. Request your voucher.

Reply
Anonymous
Not applicable

Noob question about using the Calculate and DistinctCount functions and dates

Hi all,

New to PBI and have started working on few projects and so far am a big fan of the product but I'm new and have a think is a simple quesiton but I'm stuck and seeking some help.

 

Objective -  I want to create a Measure that counts the number of distinct files, with a certain status after a certain date.

 

Attempt so far -

CNT files - Closed 22/23 FY = CALCULATE(
DISTINCTCOUNT('TABLE'[ID]), 'TABLE'[File status] = "Closed",'TABLE'[Date Closed] > 01/07/2022)

It works fine with just the File status filter but when I add the date filter I return no results yet I know there are many in the database.
All assistance would be great.
Cheers
Phil
1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @Anonymous 
Please try

CNT files - Closed 22/23 FY =
CALCULATE (
    DISTINCTCOUNT ( 'TABLE'[ID] ),
    'TABLE'[File status] = "Closed",
    'TABLE'[Date Closed] > DATE ( 2022, 7, 1 )
)

View solution in original post

4 REPLIES 4
tamerj1
Super User
Super User

Hi @Anonymous 
Please try

CNT files - Closed 22/23 FY =
CALCULATE (
    DISTINCTCOUNT ( 'TABLE'[ID] ),
    'TABLE'[File status] = "Closed",
    'TABLE'[Date Closed] > DATE ( 2022, 7, 1 )
)
Anonymous
Not applicable

@tamerj1Thank you, that works perfectly.

Can I ask, when using dates in the Calculate function is the above layout "DATE (yyyy, mm, DD)" the only way to write them? Just asing as this will be something  will need to do 100's of times.

Cheers

Phil

amitchandak
Super User
Super User

@Anonymous , if you are adding a close date filter, that is less than 1-jul-2022, this measure will not give any value as that value has been hard coded for > filter

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

@amitchandakThank you for the reply.

I'm actually only seeking a count of files that have been closed in this Finacial Year i.e. 01/07/2022 through to 30/06/2023.

 

If I use the "Filters on this visual" function I get the result i'm seeking, just can't seem to get a measure to achieve the same result.

Philandcas_0-1659540203162.png

Any other ideas.

Cheers

Phil

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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