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
Anonymous
Not applicable

DATEVALUE - Combining 2 sections of text to make a date

CONTEXT:  I work in a company who track Holiday / Leave entitlements per staff by their birth month, rather than start of financial yr / Jan-Dec. IE, Staff A has birth month of August, so his "Entitlement yr" this year is Aug18 - July 31st 19. I am tasked with recreating a report I made in Excel in power bi, which we've only just started using and I'm new to. 

 

We sum, per month, all holiday / Leave bookings made by staff and compare against their Monthly accrual which is their Annual entitlement / 12. As you can imagine, looking at a 12 month previous date range means you cross over 2 entitlement periods for most people.

 

Important to track which entitlement year a booking came out of, so in Excel I made a column with a formula which gives the value as Mmm-YY for what is their Current entitlement yr based on comparing their Birth month to todays date. For those who know excel, this formula is below. It uses DATEVALUE to turn a text combination of Birth MONTH and today's / a year ago today's YEAR value into a valid date format.

 

IF(VALUE(MONTH(TODAY()))>=MONTH(B2),DATEVALUE(TEXT(B2,"Mmm")&"-"&TEXT(TODAY(),"yy")),DATEVALUE(TEXT(B2,"Mmm")&"-"&TEXT(TODAY()-365,"yy")))

 

I'm trying to recreate the formula in DAX but have limited knowledge. I keep getting an error relating to converting text into a date, which reads: "Cannot convert value '-1905' of type text to type Date". Please see DAX below:

 

Current Birthmonth =
if(MONTH(today())>=month('Staff Info'[Birth Date]),
DATEVALUE(format(month('Staff Info'[Birth Date]),"Mmm") & "-" & format(year(TODAY()),"yyyy")),
DATEVALUE(format(month('Staff Info'[Birth Date]),"Mmm") & "-" & format(year(TODAY())-365,"yyyy")))

 

Any help would be appreciated!!! 

 

Cheers,

1 ACCEPTED SOLUTION
v-piga-msft
Resident Rockstar
Resident Rockstar

Hi @Anonymous,

 

Please try the formula below.

 

Current Birthmonth = 
IF (
    MONTH ( TODAY () ) >= MONTH ( 'Staff Info'[Birth_Date] ),
    DATEVALUE (
        FORMAT ( DATE ( 2018, MONTH ( 'Staff Info'[Birth_Date] ), 1 ), "Mmm" ) & "-"
            & FORMAT ( DATE ( YEAR ( TODAY () ), 1, 1 ), "yyyy" )
    ),
    DATEVALUE (
        FORMAT ( DATE ( 2018, MONTH ( 'Staff Info'[Birth_Date] ), 1 ), "Mmm" ) & "-"
            & FORMAT ( DATE ( YEAR ( TODAY () ), 1, 1 ) - 365, "yyyy" )
    )
)

Then you will get the output below.

 

result_.PNG

 

If you still need help, please share some data sample and your desired output so that we could help further on it.

 

Best Regards,

Cherry

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-piga-msft
Resident Rockstar
Resident Rockstar

Hi @Anonymous,

 

Please try the formula below.

 

Current Birthmonth = 
IF (
    MONTH ( TODAY () ) >= MONTH ( 'Staff Info'[Birth_Date] ),
    DATEVALUE (
        FORMAT ( DATE ( 2018, MONTH ( 'Staff Info'[Birth_Date] ), 1 ), "Mmm" ) & "-"
            & FORMAT ( DATE ( YEAR ( TODAY () ), 1, 1 ), "yyyy" )
    ),
    DATEVALUE (
        FORMAT ( DATE ( 2018, MONTH ( 'Staff Info'[Birth_Date] ), 1 ), "Mmm" ) & "-"
            & FORMAT ( DATE ( YEAR ( TODAY () ), 1, 1 ) - 365, "yyyy" )
    )
)

Then you will get the output below.

 

result_.PNG

 

If you still need help, please share some data sample and your desired output so that we could help further on it.

 

Best Regards,

Cherry

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

That has indeed worked! Thank you very much!

 

Out of curoisity - I see the main change is adding a ,1) after the Format( Date ( 2018, Month ('staff info[birth date]) part. What does this 1 do exactly as I did not see that section on the Syntax guide as I was typing it out.

 

Thanks once again.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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.

Top Solution Authors
Top Kudoed Authors