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

CALCULATE measure with date filter

Hello! 

My data set: 

'Date'[Date] - Default data table, used as report filter 

 

Table:

Product_IDDate_Start...
243220.02.2022 
352221.02.2022 
...... 

 

Task: Count number of distinct Product which started at given date

 

MEASURE1 = CALCULATE(DISTINCTCOUNT(Table[Product_ID]), Table[Date_Start] = MAX('Date'[Date]))
gives empty result for any date
but
MEASURE2= CALCULATE(DISTINCTCOUNT(Table[Product_ID]), Table[Date_Start] = MAX('Date'[Date])-1)
gives good result for any date, but its moved by one day 
 
I tried using solution which i found here on forum wich is: 
MEASURE3= CALCULATE(DISTINCTCOUNT(Table[Product_ID]), FILTER(Table, Table[Date_Start] = MAX('Date'[Date])))
but result is still empty

No error reported in PBI
 
I want to use relative date in raport to present number of products for yesterday, today and tommorow, so i need it to work without this (-1) element. It seems to bo so simple measure, but it gave me headache.
 
2 ACCEPTED SOLUTIONS
Jos_Woolley
Solution Sage
Solution Sage

Sounds like the entries in 'Date'[Date] aren't formatted as proper dates. Hence the conversion to a correct date by a simple mathematical operation (for example, your subtraction of 1).

Regards

View solution in original post

Anonymous
Not applicable

Ok, so everything looked fine at first glance. 
But changing date table from defined in report by:

Date = CALENDAR(DATE(1990, 01,01),DATE(2099,12,31))

to Data table generated in power query solved the issue.

Thanks for guidance. 

View solution in original post

5 REPLIES 5
Jos_Woolley
Solution Sage
Solution Sage

Sounds like the entries in 'Date'[Date] aren't formatted as proper dates. Hence the conversion to a correct date by a simple mathematical operation (for example, your subtraction of 1).

Regards

Anonymous
Not applicable

Ok, so everything looked fine at first glance. 
But changing date table from defined in report by:

Date = CALENDAR(DATE(1990, 01,01),DATE(2099,12,31))

to Data table generated in power query solved the issue.

Thanks for guidance. 

Anonymous
Not applicable

Date = CALENDAR(DATE(1990, 01,01),DATE(2099,12,31))


and column: 'Date'[Date], data type is "Date"

Jos_Woolley
Solution Sage
Solution Sage

Hi,

MyMeasure :=
VAR ThisDate =
    MAX( 'Date'[Date] )
RETURN
    CALCULATE(
        DISTINCTCOUNT( 'Table'[Product_ID] ),
        'Table'[Date_Start] = ThisDate
    )

which is identical to:

MyMeasure :=
VAR ThisDate =
    MAX( 'Date'[Date] )
RETURN
    CALCULATE(
        DISTINCTCOUNT( 'Table'[Product_ID] ),
        FILTER(
            ALL( 'Table' ),
            'Table'[Date_Start] = ThisDate
        )
    )

Regards

Anonymous
Not applicable

I have already tried this alternative , no change. As in my post, it works with 

 ThisDate =
    MAX( 'Date'[Date] ) - 1

 

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.