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 August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Cannot convert value '' of type Text to type Number.

Hi

 

I am trying to create a new column with the following logic, but get the error message:
Cannot convert value '' of type Text to type Number.

This is my logic (mo_date is formatted as a shorthand date dd/mm/yyyy):

FY =
if(month(dim_mo[mo_date]) >=9,
format(dim_mo[mo_date], "YY") & "/" & ((format(dim_mo[mo_date], "YY")*1)+1),
((format(dim_mo[mo_date], "YY")*1)-1) & "/" & format(dim_mo[mo_date],"YY") )
 
Any idea how to get around this please?
2 ACCEPTED SOLUTIONS
v-yalanwu-msft
Community Support
Community Support

Hi, @Anonymous ;

Because format([date],"YY'") becomes text format. It is no longer possible to calculate, for example, in 2021, it will become "21" after format, and the format is text format *1-1 and cannot be calculated. So you can change to the following dax.

FY =
IF (
    MONTH ( dim_mo[mo_date] ) >= 9,
    FORMAT ( dim_mo[mo_date], "YY" ) & "/"
        & RIGHT ( YEAR ( dim_mo[mo_date] ) + 1, 2 ),
    RIGHT ( YEAR ( dim_mo[mo_date] ) - 1, 2 ) & "/"
        & FORMAT ( dim_mo[mo_date], "YY" )
)


Best Regards,
Community Support Team _ Yalan Wu
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

yes probaby you would need to handle your blanks by using an if statement something like

if(isblank(date), blank(), your conversion)





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




View solution in original post

8 REPLIES 8
v-yalanwu-msft
Community Support
Community Support

Hi, @Anonymous ;

Because format([date],"YY'") becomes text format. It is no longer possible to calculate, for example, in 2021, it will become "21" after format, and the format is text format *1-1 and cannot be calculated. So you can change to the following dax.

FY =
IF (
    MONTH ( dim_mo[mo_date] ) >= 9,
    FORMAT ( dim_mo[mo_date], "YY" ) & "/"
        & RIGHT ( YEAR ( dim_mo[mo_date] ) + 1, 2 ),
    RIGHT ( YEAR ( dim_mo[mo_date] ) - 1, 2 ) & "/"
        & FORMAT ( dim_mo[mo_date], "YY" )
)


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

Ashish_Mathur
Super User
Super User

Hi,

Try this calculated column formula

=if(month(dim_mo[mo_date]) >=9,year(dim_mo[mo_date])&"/"&year(dim_mo[mo_date])+1,year(dim_mo[mo_date])-1&"/"&year(dim_mo[mo_date]))

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

Thanks for your suggestion. I have tried this but get the following error message:

The syntax for '+' is incorrect.

Mine is a calculated column formula in DAX not a custom formula in M.  Ensure that you are writing that as a calculated column formula in DAX.  If it still does not help, then share the download link of your PBI file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
vanessafvg
Super User
Super User

is your new column datatype text or a whole number?

 

vanessafvg_0-1667855401623.png

vanessafvg_1-1667855422944.png

what are you expecting?





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




Anonymous
Not applicable

I have looked at the date field and can see I have (blanks) in there. Would that be what is causing this not to work? 

yes probaby you would need to handle your blanks by using an if statement something like

if(isblank(date), blank(), your conversion)





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




Anonymous
Not applicable

It's a text. The output I am expecting is the same are you're getting so not quite sure why mind doesn't work. Thanks for checking

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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