How to convert a specific text string to today's date in Power BI - type-conversion

I have a table with a column called that contains text. Most of the values are years. However, some have the value "present" to represent groups that are still currently active. I want to convert those values to today's year, and convert the column type to date (specifically year type). I want to avoid creating a new column if possible.

Please see below for the DAX language that worked.
= Table.ReplaceValue(#"Extracted Year2",null,DateTime.LocalNow() ,Replacer.ReplaceValue,{"Disbanded"})

Related

How to convert a field with 202008 to a date in Tableau

I am trying to convert a field that contains strings such as 202008, 202108 to a date field. I have tried the date() function, clicking on the measure and converting it to a date. I have also tried DATE(LEFT([Month],4)+"-"+RIGHT([Month],2)+"-01") but that will only return the year.
Using Tableau Desktop 2021.1, when I change the data type from String to Date, Tableau translates the strings to 8/1/2020 and 8/1/2021. If you are using an earlier version of Desktop, it is possible that this functionality is not present.
However, if changing the data type isn't working for you, the calculated field code you provided should actually work, you just need to change the date part from Year to Month/Day/Year using the Custom date part option.

Converting number to date format using Power Query Editor

I need help to convert Numbers into date format using Power Query Editor in either Excel or PowerBI
The date appears in number form like this 930101 and I want to convert it to normal Uk date format
Not sure which one is month and which one is date among "0101" in your string. But you can handle this your self and follow this below steps for get your required output in Power Query Editor-
First, split your string value using fixed 2 character and your data will be divide into 3 column now. define which one is Year, Month and Day.
Now, merge those 3 column maintain the UK pattern DD/MM/YY using a separator "/" and you will get a string like "01/01/93".
Finally, create a custom column using the below code-
Date.From([Merged],"en-GB")
Here is the final output-
In the above image, you can see the date in still US format just because of my Laptop's locally setup.

DAX and FORMAT function

i have a field for date with date, month and year.In my visualization, I need date to be displayed in (MON-Year) format.
I switched to data view, created calculated column with
Mon-Year = FORMAT('table'[Date],"YYYY-MM")
Now it's getting displayed as (YEAR and Month number) but I want to change it as month name.
After changes in data view, when I close apply, the column is present but there is no data type visible.
Should I create different calculated fields for year and month separately and then concatenate it?
any help would be appreciated.
If you want month first, then maybe you should specify it that way.
Mon-Year = FORMAT('table'[Date],"MMM-YYYY")
This may be useful for you:
https://learn.microsoft.com/en-us/dax/custom-date-and-time-formats-for-the-format-function

Converting null values in date column to "N/A" in tableau

We have a date column which has a lot of Null Values. We want to replace these null values with "N/A", however for date columns I dont see aliases where I can change it with a click of a button.
So I wrote the following calculation :
IFNULL(str([Arrival Date]),"N/A")
Since this calculation is now a string, I cannot change the format of the date like I could for any normal date column.
Since this new calculated field has string values, I know i cannot convert it back to date. So how can i now handle the date formats ?
BLANK is the default value for NULLin Tableau.
Set how tableau treats these values
Right Click Measure> Format
Select Special Values (bottom most) and
change the value to NA
See this screenshot
In case it's a discrete value refer to Tableau KB: Replacing Null Literals

how to take off time in date time tabular model

I have a date dimension table and I have a Date column in that table it has datekey, fulldatekey, Date, DayofMonth, Dayofyear, month, ect. the Date column only has yyyy-mm-dd, but when I bring it into my tabular cube model it appends a 12:00:00 A.M time to the end of it. I was wanting to know how do I remove the time to only have the date. I am building a tabular cube in ssdt to bring into power bi
According to this Microsoft site,
In contrast to Microsoft Excel, which stores dates as a serial number,
PowerPivot date functions always return a datetime data type. However,
you can use formatting to display dates as serial numbers if you want.
From my "limited" experience, you can change the date formatting in one column, but when you reference it from another column, it will once again include the 12:00:00 AM time as part of the date when it displays in the new column. I assume this is because, as Microsoft says in that website,"PowerPivot date functions always return a datetime data type."
Edit Query -> Transform Tab -> Choose Data Type
That's my best guess.