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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
BeenBee
New Member

Adding Calculated Column to Date Table based on Date Ranges in Another table

Hi All,

I am looking for some help adding a column to my date table based on date start and end found in another table.

What I am trying to do is to add a column to my date table which specifies for each date in the table, which semester it falls into. The dates for each semester can be found in the Semester Date table. There is a start and end date for each semester.

I have tried to adapt the solution found in another post. The issue I am having is that the column is currently only returning the final semester found in the Semester Date table.

 

The DAX I have is

Semester Date = VAR _a =
    SELECTEDVALUE ( 'Date'[Date] )
RETURN
    CALCULATE (
      MAX( 'Semester Dates'[Academic Semester]),
        FILTER (
            ALL ( 'Semester Dates' ),
            'Semester Dates'[Start]>= _a
                && _a <= 'Semester Dates'[End]
        )
    )

Date Table;

BeenBee_0-1736954241879.png

Semester Date Table;

 

BeenBee_1-1736954295812.png

Any help would be greatly appreciated.

 

Many thanks

1 ACCEPTED SOLUTION

Thank you very much for your response. I have made an adjustement to my original code and have had success with the SELECTEDVALUE

Semester Date = VAR _a =
    SELECTEDVALUE ( 'Date'[Date] )
RETURN
     CALCULATE(
        MAX('Semester Dates'[Academic Semester]),
        FILTER(
            'Semester Dates',
            [Date] >= 'Semester Dates'[Start] &&
            [Date] <= 'Semester Dates'[End]
        )
    )

 I aslo found some issues with the dates in my Semester Dates Table, which I have addressed and is working correctly now.

Thank you for the help.

View solution in original post

2 REPLIES 2
johnt75
Super User
Super User

SELECTEDVALUE won't work in a calculated column, you can use

Semester Date = 
VAR _a = 'Date'[Date]
RETURN
    CALCULATE (
      MAX( 'Semester Dates'[Academic Semester]),
        FILTER (
            ALL ( 'Semester Dates' ),
            'Semester Dates'[Start]>= _a
                && _a <= 'Semester Dates'[End]
        )
    )

Thank you very much for your response. I have made an adjustement to my original code and have had success with the SELECTEDVALUE

Semester Date = VAR _a =
    SELECTEDVALUE ( 'Date'[Date] )
RETURN
     CALCULATE(
        MAX('Semester Dates'[Academic Semester]),
        FILTER(
            'Semester Dates',
            [Date] >= 'Semester Dates'[Start] &&
            [Date] <= 'Semester Dates'[End]
        )
    )

 I aslo found some issues with the dates in my Semester Dates Table, which I have addressed and is working correctly now.

Thank you for the help.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.