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
msommerf
Helper III
Helper III

Find value between 2 dates

Can somebody please help?

I have a table which has financial periods which are defined between two dates as shown:

 

PERIODS TABLE

START DATE     END DATE     PERIOD

30/06/2013      27/07/2013        1

28/07/2013      24/08/2013        2

25/08/2013      28/09/2013        3

 

I have a date table with my dates in it:

 

DATES

DATE

01/07/2013

02/07/2013

28/07/2013

27/08/2013

 

I am trying to add a calculated column to add my periods to my date table as follows:

 

DATE            PERIOD

01/07/2013     1

02/07/2013     1

28/07/2013     2

27/08/2019     3

 

I have tried the following DAX but get an error:

 

Column = calculate (

     values (    PERIOD TABLE [PERIOD]),

     filter (PERIOD TABLE,

     PERIOD[START DATE]<=MAX(DATE[DATE]) && PERIOD[END DATE]>=MIN(DATE[DATE]))))

 

The resultant column is blank.

 

Can anyone advise as to what I am doing wrong?

Any assistance appreciated.

1 ACCEPTED SOLUTION
jdbuchanan71
Super User
Super User

Hello @msommerf 

Give this a try for making the calculated column in your date table.

Period = 
CALCULATE (
    MAX ( 'PERIOD TABLE'[Period] ),
    FILTER (
        'PERIOD TABLE',
        'PERIOD TABLE'[Start Date] <= Dates[Date] &&
        'PERIOD TABLE'[End Date] >= Dates[Date]
    )
)

View solution in original post

2 REPLIES 2
jdbuchanan71
Super User
Super User

Hello @msommerf 

Give this a try for making the calculated column in your date table.

Period = 
CALCULATE (
    MAX ( 'PERIOD TABLE'[Period] ),
    FILTER (
        'PERIOD TABLE',
        'PERIOD TABLE'[Start Date] <= Dates[Date] &&
        'PERIOD TABLE'[End Date] >= Dates[Date]
    )
)

Perfect! this works for me. Many thanks for your assistance.

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.