Power BI How to extract month and year from a date - date

I have a column containing dates in the following format: "28-SEP-2018 12.40.00", does anyone know how to extract the month and year from the date in a new column (i.e. Sep- 2018), via producing a measure.

#navee1990 the measure to extract the date and year is as follows
= MONTH([date] & YEAR([date])
Or the long way
CONCATENATE(MONTH([date]),YEAR([date]))

Assuming the type of the column is Text and you want the new values to be displayed as SEP-2018 rather than 09-2018:
You would need to create a new column with DAX as c1 = MID(Table2[Column1],4,8)
In case if the column is of type: DateTime ; then use the below DAX for new column :FORMAT(Table2[Column1],"MMM-YYYY")

New Date =FORMAT([date], "MMM") & "-" & YEAR([date])
This would give you a column with text data type. You can further create a column to sort the New Date column as per calendar chronology.

Related

Sisense, display number of days in date filter

Have a date filter on the dashboard that allows for a custom date range:
Dashboard Date Filter
How can I add a the number of days in the filter to a formula? Just trying to show the number of days in column of a pivot table. In this example the date range is 45 days. The dataset doesn't have one record for each day, so a distinct count of days from the data set returns 42.
Is it possible to use the date from and date to filter values in formula? DDIFF([datefilter-from], [datefilter-to])
Extract the date from the fact table and create a dimension table which will contain all the dates.
Link the date column from fact table and dimension table. Use the dimension table's date column in filters.

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

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

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"})

Power Query - Subtract the earliest date in one column from the record-specific date in another column

Every month I download a set of data into a report. That data consists of multiple records and each record has a record specific date as well as having the month end report date on the record's data-row.
I have used Power Query to upload all of these month end reports. I want use Power Query to be able to compare the column of record dates with the earliest date in the column of report dates to see if anybody has fiddled any data entry. The query table has the following headings.
Record ID Record Date Report Date
I've tried adding a custom column using the formula = if Record Date < List.Min(Report Date) then "Old" else "New"
this didn't work and I've spent ages trying to get a solution. I've also tried using Groups to get the minimum value, but I lose all of the other columns, which I want to keep. Any help really appreciated.
You have to refer to the fields in [], so here [Report Date]
To pick a column use Source[Field], so here #"PriorStep"[Report Date]
The List.Min function is not pulling as a number so you cant use <
Insert a Number.From in front of the calculation to convert to number
Same need to add Number.From in front of [Record Date] pulling as a date
Combined code:
#"Added Custom" = Table.AddColumn(#"PriorStep", "Custom", each if Number.From([Record Date])<Number.From(List.Min(#"PriorStep"[Report Date])) then "Old" else "New")

PostgreSQL filter data based on star date and end date on result column

In above image mon_year column contain month and year data.I have start date and end date and want to filter on mon_year column.
ex.I am selecting start date is 22-06-2017 and end date 20-01-2018.So last two row will not come in result.I am using date_part PostgreSQL function but its not working.
right now I have separate column of month and year.