The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
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
Solved! Go to Solution.
@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
Proud to be a Super User! |
|
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.
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.
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.
@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
Proud to be a Super User! |
|