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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Carrhill
Helper I
Helper I

Create a Measure which Filters on a specific date range

Hi,

I need to create a Filter Measure to show the Item IDs which were opened during a specified date range (30 Jan 2021 - 28 Jan 2022).

 

Here's what I have so far but now I'm stuck...Please help!

 

Opened_In_FY22 = CALCULATE(sum('Table'[Item ID]),FILTER('Table', 'Table'[Opened Date] ????
 

 

Thanks!

1 ACCEPTED SOLUTION
Samarth_18
Community Champion
Community Champion

Hi @Carrhill ,

 

If its static date range then you can try this:-

Opened_In_FY22 =
CALCULATE (
    SUM ( 'Table'[Item ID] ),
    FILTER (
        'Table',
        'Table'[Opened Date] >= DATE ( 2021, 01, 30 )
            && 'Table'[Opened Date] <= DATE ( 2022, 01, 28 )
    )
)

 

or if its coming from date slicer then

 

Opened_In_FY22 =
var min_date = min(date_slicer[date])
var max_date = max(date_slicer[date])
CALCULATE (
    SUM ( 'Table'[Item ID] ),
    FILTER (
        'Table',
        'Table'[Opened Date] >= min_date 
            && 'Table'[Opened Date] <= max_date 
    )
)

 

Thanks,

Samarth

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

View solution in original post

2 REPLIES 2
Samarth_18
Community Champion
Community Champion

Hi @Carrhill ,

 

If its static date range then you can try this:-

Opened_In_FY22 =
CALCULATE (
    SUM ( 'Table'[Item ID] ),
    FILTER (
        'Table',
        'Table'[Opened Date] >= DATE ( 2021, 01, 30 )
            && 'Table'[Opened Date] <= DATE ( 2022, 01, 28 )
    )
)

 

or if its coming from date slicer then

 

Opened_In_FY22 =
var min_date = min(date_slicer[date])
var max_date = max(date_slicer[date])
CALCULATE (
    SUM ( 'Table'[Item ID] ),
    FILTER (
        'Table',
        'Table'[Opened Date] >= min_date 
            && 'Table'[Opened Date] <= max_date 
    )
)

 

Thanks,

Samarth

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

Syk
Super User
Super User

Instead of FILTER use the DATESBETWEEN function. If you need specific dates you can just type them with some double quotes!

CALCULATE(SUM('Table'[Item ID], DATESBETWEEN('Table'[Date],MAX('Table'[Opened Date]),TODAY()))

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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