Power BI - Date Format - date

I'm attempting to change the date format of a column from 01 Jan 2021 to 01 Jan 21 but it looks like that's not one of the formats available in power Bi. Is there a formula that might do this for me?
Kind regards,
Cian

Is possible to do what you want without using any formula.
First, go to the Model View and select the desired column. In my case is Date2. Then open the Properties tab that is at the left.
Now, go to Formatting, select Custom and at the Custom format textbox paste d MMM yy
By doing that you should get the expected result.

Related

PowerBI Matrix with Year and Month

In the matrix below I have data from Jan 2020-Jan 2021, where the Jan column has the data from both 2021 and 2021. Is there any way to have the matrix add another column for Jan 2021 instead of aggregating that in with the Jan 2020 data?
Chose Year and Month in the date hierarchy column and then in the matrix click "expand all down one level in the hierarchy.
I am new to Power BI and I was wondering recently myself about something similar.
You can create a new column (text format) and combine month and year.
Date
Date Modified
dd-MM-yyyy
yyyy-MM
or
Date
Date Modified
dd-MM-yyyy
yyyy-MM (MMMM)
or
Date
Date Modified
dd-MM-yyyy
yyyy-MM (MMM)
It is not the most elegant solution, it changes a bit what is displayed (not simply months in the headers), it has a few disadvantages but it works.
I would be curious myself whether a better solution exists.
If you click on the date column you are using [InvoiceDate] and select the date option, it will separate out the two date values.
currently it is in a hierarchy showing just the month values but not the actual date
i have this but mine stays summed up at the year level even though the 'month' is expanded under the TimeByDay...
If I take out the year it will provide it like above but combines both... or as is it puts columns in the year

How to show month prior the end date the user has chosen in Webi 4.1

I'm creating a dashboard in Webi 4.1. When I run the prompt I choose the start and end dates for the report. However, I have a line chart that shows the volume trend by month over time and I want it to exclude the end date and instead show the month right before that.
Example: I choose June 1 2016 as the start date and June 14 2017 (today's current date) as the end date. However for the line graph I want it to show Jun 1 2016 - May 31 2017.
Date functions in BO aren't quite as mature as they should be.
You can retrieve the value entered in the prompt, but it will be a string. First, we'll need to convert it to a date type. We'll call this variable [End Date].
=ToDate(UserResponse("Enter value for End Date:");"M/d/yyyy hh:mm:ss a")
This assumes that the prompt text is "Enter value for End Date:", and your local date format is "M/d/yyyy hh:mm:ss a"). Adjust as necessary.
Once you have that, it's a relatively simple calculation of subtracting the day of the month from the date:
=LastDayOfMonth(RelativeDate([End Date];-DayNumberOfMonth([End Date])))
Finally, you can filter the chart to show dates less than this.
Edit to add filtering logic
To use the above in a filter, you will need another variable to determine whether or not a row should be displayed. Assuming the chart's displayed date comes from an object named [Date], you could do the following:
=If [Date] < LastDayOfMonth(RelativeDate([End Date];-DayNumberOfMonth([End Date]))) Then 'Y' Else 'N'
Create this as a variable named [DisplayDate], then simply apply a filter to the chart with [DisplayDate] = 'Y'

Xpath current date

I have a webpage where a row displays name, relation and date. I want to search for the matching row as per my values. Using Xpath, I have built the below mentioned code. The only problem is the last part (the date). I want to pick up the current date and fit it into the search query..i.e. instead of 30 Sep 2013, I want it to search for 01 Oct 2013 (assuming today is this date).
Any clue how can i do that??
$x('//tr[descendant::b[text()="text1"] and descendant::a[#class="bill" and text()="for Automation"] and descendant::td[text()="30 Sep 2013"]]')
You have to build the expression dynamically and append the date string at the end based on some date object. The specific implementation depends on which programming language you're using

I need to pull just the year from a field

I have a date field (work_date) that I just need the 4 digit year from and be in number form. the field looks like this 2020-04-28 00:00:00.000 I just need the 2020 from it.
In sql studio this works,
select left((convert(varchar(4),[Work_Date],112)),4)
but in crystal reports it say missing ( by convert
Try this:
Year({table.field})
Or this:
DatePart('yyyy',{table.field})
DatePart yyyy
DATEPART (Transact-SQL)
No need to use any formula, just right click the report field and format it, click customize and get the output you desire, its just the same as you format in excel

Crystal reports Crosstab date grouping.

I've created a report using the crosstab control which groups the data by date in columns. I'd like to take all of the dates that are earlier than the 1st of the current month (when the report is run) and combine them and the data being summarized into one column called Previous.
So instead of seeing something like this:
Oct Nov Dec Jan Feb Mar Apr May Jun Jul
I've see something like this:
Previous Jan Feb Mar Apr May Jun Jul
Is there a way of doing this in CR XI?
You would have to create a formula to do this (or probably two formulas one to get them in the correct order and another to display the correct string):
grouping formula: if {table.datefield} < currentdate then '0000' else cStr({table.datefield}, 'yyMM')
display formula: if {table.datefield} < currentdate then 'Previous' else cStr({table.datefield}, 'MMM')
ADDED SCREENSHOT
The answer was actually a modification of Lee's answer.
if {Command.ReqDate} < date(year({?StartDate}),month({?StartDate}),1) then dateadd('m',-1,{?StartDate}) else {Command.ReqDate}
use this to group on in the CT set to monthly
right click on the column header
select Format field,
select common tab
select display string formula
if currentfieldvalue < date(year({?StartDate}),month({?StartDate}),1) then 'previous'
else totext(currentfieldvalue,'MMM')