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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Beginner101
Regular Visitor

Need Assistance Converting a column

I'm fairly new to PowerBi.  

 

I have a PowerBi dashboard that I was able to create in 2024.  I am in the process of adding and updating my pbi to reflect 2025 data. I have a column called "Date Replaced".  The data in this column is "pre-2024", and then replacement dates of mm/dd/yyy.  So 2/17/24, 5/25/24, 1/15/25 and so forth.  I am trying to convert this data to show just mm/yy BUT still keep pre-2024 in there. So changing it to date does not work.  I have tried creating a new column in power query using the following:

 

= if Text.StartsWith([Date Replaced], "Pre-2024") then "Pre-2024"   else Date.ToText([Date Replaced], "MM/yy")

 

It worked for "pre-2024" but for the dates I get the following error :

Expression.Error: We cannot convert the value "5/28/2024" to type Date.

Details:

    Value=5/28/2024

    Type=[Type]

 

So then I try to create a new column in DAX using the following:

Date_Display = IF(ISBLANK('MyTable'[Date Replaced]), BLANK(), IF(  'MyTable'[Date Replaced] = "Pre-2024", "Pre-2024",         FORMAT('MyTable'[Date Replaced], "MM/yy")))

 

It accepts my formula but when the new column is created the dates are still formatted "mm/dd/yyy"

 

Any help with this would be greatly appreciated. I'm not sure if I am missing something simple. But I keep going in this endless loops. 

 

The end result I'm looking for, is to have my Replacement Date slicer in my dashboard to show the dates of completions by month and then pre-2024.  Since anything completed before 2024 does not have a specific month or day. 

 

THANK YOU 

1 ACCEPTED SOLUTION
bhanu_gautam
Super User
Super User

@Beginner101 In the Power Query Editor, go to the "Add Column" tab and click on "Custom Column".

= if Text.StartsWith([Date Replaced], "Pre-2024") then "Pre-2024"
else Date.ToText(Date.FromText([Date Replaced]), "MM/yy")

 

Ensure that the dates in the "Date Replaced" column are in a recognizable date format. If they are not, you might need to transform them into a date format first using Date.FromText.

After adding the custom column, click on "Close & Apply" to apply the changes and return to the Power BI Desktop and use it as slicer

 




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






View solution in original post

4 REPLIES 4
v-hashadapu
Community Support
Community Support

Hi @Beginner101 , Please let us know if your issue is solved. If it is, consider marking the answers that helped 'Accept as Solution', so others with similar queries can find them easily. If not, please share the details.
Thank you.

v-hashadapu
Community Support
Community Support

Hi @Beginner101 , Thank you for reaching out to the Microsoft Community Forum.

Please let us know if your issue is solved. If it is, consider marking the answers that helped 'Accept as Solution', so others with similar queries can find them easily. If not, please share the details.
Thank you.

v-hashadapu
Community Support
Community Support

Hi @Beginner101 , Thank you for reaching out to the Microsoft Community Forum.

Please let us know if your issue is solved. If it is, consider marking the answers that helped 'Accept as Solution', so others with similar queries can find them easily. If not, please share the details.
Thank you.

bhanu_gautam
Super User
Super User

@Beginner101 In the Power Query Editor, go to the "Add Column" tab and click on "Custom Column".

= if Text.StartsWith([Date Replaced], "Pre-2024") then "Pre-2024"
else Date.ToText(Date.FromText([Date Replaced]), "MM/yy")

 

Ensure that the dates in the "Date Replaced" column are in a recognizable date format. If they are not, you might need to transform them into a date format first using Date.FromText.

After adding the custom column, click on "Close & Apply" to apply the changes and return to the Power BI Desktop and use it as slicer

 




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors