Custom date format on PowerBI - date

I'm assembling data tables in PowerBI, whose rows and columns are date type, with the format that the program offers, I have managed to change the format to 'January 2018', but I want to visualize 'jan-2018', and that format is not included in the program, what should I do to get a date format like this?
I can't find any answer about my problem on any website.
The code I found is this:
= Table.TransformColumnTypes(#"Promoted Headers",{{"Segmento Cliente", type text}, {"Paquete", type text}, {"Fecha cosecha", type date}, {"Fecha proyectada", type date}, {"Valor", Int64.Type}})
I don't know what to do to change the format.
Help me please, thanks.
EDIT: I tried this, but i get a type text column, and what I want is a type date. Any idea?
Right click your table on the right side, add new column, write code (in data or report view, not in query):
Custom Date = FORMAT('TABLE NAME'[TABLE COLUMN]; "FORMAT")
In your case the format will be MMM - YYYY
To add upper/lower case, put UPPER or LOWER before the FORMAT
Example all uppercase:
Custom Date = UPPER(FORMAT('TABLE NAME'[TABLE COLUMN]; "FORMAT"))

Right click your table on the right side, add new column, write code (in data or report view, not in query):
Custom Date = FORMAT('TABLE NAME'[TABLE COLUMN]; "FORMAT")
In your case the format will be MMM - YYYY
To add upper/lower case, put UPPER or LOWER before the FORMAT
Example all uppercase:
Custom Date = UPPER(FORMAT('TABLE NAME'[TABLE COLUMN]; "FORMAT"))

Related

Date Format - Change format of Month from String to Numeric Value

I would think this is relatively straight forward but cant find documentation on how to do it(or the correct syntax to use) and my messing around hasn't worked so far.
For Dates we have a custom format called Month /Day /Year. This pulls back a the date(as a date type) in date format as such:
"14 April 2003"
The code behind this is:
(DATEPART('year', [Close Date])*10000 + DATEPART('month', [Close Date])*100 + DATEPART('day', [Close Date]))
What I want to get back is the month is numeric format like:
"14.04.2003"
Is it simply changing the "month" part in the code to a different type? Has any one come across this?
Cheers
lampbob, I'd just use date formatting which will mean you will still be able to use all the date-fields flexibility that Tableau provides.
Select Custom format with the following input:
dd.mm.yyyy
See the screen below for more details:
This can be easily achieved using the 'Format' option in Tableau. Here are the steps to follow to format the date field as you have specified.
Add Date field to your Rows/Columns field on a Tableau worksheet.
Set the format of the Date to be DAY(Date).
Click on options for 'DAY(Date)' and go to 'Format...'
On the Format DAY(Date) panel, go to Scale -> Dates.
Select 'Custom' option and type in 'mm.dd.yyyy'. Now the date will be in the string format you need.
Screenshots:
String format for date,
Changing to 'DAY' and 'Format...'
If you are only concerned about how the date is presented, then leave the datatype as a date, and use a custom format string via the format pane to display it as desired.
Followed your advice and just had to change the date pill, in the column field, to a continuous value. Then right clicked -> format -> Scale -> custom. Then used the above suggested format setting. Thanks Petr, woodhead92.

IReport BigDecimal format "R$ #,##0.00" Monetary Value in Charts

I have a JasperReports chart, In the report, the field $F{soma} is BigDecimal, at thedatabase MySQL is Decimal(19,2). I'm using this sql: select SUM(valor) as soma to get the field $F{soma}.
Printing just $F{soma} i get labels like : 1.500,20. Without format expression. What i need is to show labels like : "R$ 1,520.20".
Tried this:
new java.text.DecimalFormat("R$ #,##0.00").format(Double.valueOf($F{soma}))
But no success, so if someone can point me a direction, i'll be thankful.
Have not reputation to post images, but links bellow are about the field types..
Field in MySQL:
Labels being printed (without format expression)
If your $F{soma} is a BigDecimal field then just write
new java.text.DecimalFormat("R$ #,##0.00").format($F{soma});
Use an instance of NumberFormat that has the right Currency to format the value. If the default Locale is giving you a problem,
Use NumberFormat.getCurrencyInstance(Locale inLocale) with the Locale you want, e.g.:
NumberFormat.getCurrencyInstance(Locale.US);
Use NumberFormat.getInstance() and setCurrency() to set the Currency you want, e.g.:
NumberFormat f = NumberFormat.getCurrencyInstance();
f.setCurrency(Currency.getInstance(…));

Google Sheets converting dates to numbers

I've run into a problem and haven't been able to find a solution for this via Google.
Using Google Sheets, I have a series of dates in the DD/MM/YYYY format in a column, and I'm filtering them based on info in another column with this formula in column G:
=ARRAYFORMULA(FILTER(D:D, B:B=B2))
where the dates are in column D. For example, 5/20/2013.
This works fine, but next, I want to add a string to the front of the dates like so:
=ARRAYFORMULA("End: "&FILTER(D:D, B:B=B2))
The dates are converting into numbers. So 5/20/2013 becomes End: 41414 instead of End: 5/20/2013, which is what I need.
Further, this happens whenever I try to reference a cell with a date in it in any formula. I have another column that puts together some values from other columns like this:
=IF(B:B=B2,ARRAYFORMULA(F2&" "&E2),"")
I want to add the date to that, like so:
=IF(B:B=B2,ARRAYFORMULA(F2&" "&E2&" "&G2),"")
The result I'm getting is the same, where I should see 5/20/2013 I'm instead getting 41414.
Can anyone tell me what's going on and how I can prevent it from converting my dates to numbers like that? Thanks!
In addition to Chris' answer: just converting to text should also work:
=ARRAYFORMULA("End: "&FILTER(to_text(D:D), B:B=B2))
You can format the formula output using TEXT, for example:
=ARRAYFORMULA("End: "&FILTER(TEXT(D:D,"mm/dd/yyyy"), B:B=B2))
=IF(B:B=B2,ARRAYFORMULA(F2&" "&E2&" "&TEXT(G2,"mm/dd/yyyy")),"")

Importing data time changed to Date on import

I have a text file that I want to import into Matlab using the import data tool.
The original format of one line is:-
20150904 060004 .... ..... .....
Matlab has 200150904 in the first column, which I have set the formatting to yyyyMMDD and that works fine. For the second column, 060004, I have set the formatting to HHmmss but when the date is imported it changes it to a date format and is displaying 07-Sep-2015 for that cell?
This soltuion has to be fitted to the type of your input but lets say each colum is a cell, then this would work:
X=[{'20150904'} {'060004'};...
{'20150904'} {'070004'};...
{'20150904'} {'080004'}];; % as example if the input happen to be a cell array
Y=datetime(cell2mat(X) ,'InputFormat','yyyyMMddhhmmss','Format','yyyy-MM-dd HH:mm:SS')%the 'Format' Parameter determines how the date is visualized for you

Return different datatypes crystal formula

I have a requirement where depending on the parameter selected the table field should be displayed as text or date. For eg, if the user selects a true, the OriginDate field which is a datetime type should be displayed as a date in the report else should be displayed as a text. I tried creating a formula an doing something like below, and then placing the formula in the details section of the report but it doesnt work due to different datatypes returned.
if {?Mailmerge}=true then
ToText({Travel.OriginDatetime}, "M/d/yy")
else
{Travel.OriginDatetime}
Is there a way I can accompalish the above requirement so that I do not end up creating 2 reports one with field displayed as text and other as date?
Try creating a formula that returns your field as a string totext({Travel.OriginDateTime},"M/d/yy") and overlay it with the original field {Travel.OriginDateTime} and conditionally suppress them based on the value of {?MailMerge} such that only one shows in any one instance of the report.
If I'm following you, you want to only show M/d/yy when ?MailMerge is true, otherwise yuo want to show the full date?
You can't show different datatypes in the same formula, so just convert them both parts of the conditional statement into strings:
if {?Mailmerge}=true then
ToText({Travel.OriginDatetime}, "M/d/yy") // 8/30/12
else
ToText({Travel.OriginDatetime}, "M/d/yy hh:mm:ss") // 8/30/12 02:06:00
I don't know what exactly your dates look like in the database, but you can use the above as a guideline into formatting your date based on the ?MailMerge parameter.