Generate dates from start date to end date - powerbi

I need to generate the dates from start date and end date. For example, Start date is 11th March 2022 and the end date is 11th March 2023.
I have been able to generate the dates from 11th March 2022 to 1st March 2023 using the below formula in power query
let
StDt = [#"Grant date #(lf)(dd/mm/yyyy)"],
AllDates = {Number.From([#"Grant date #(lf)(dd/mm/yyyy)"])..Number.From([#"Vesting end date (each period)"])},
StofMonthDates =
List.Distinct(List.Select(List.InsertRange(List.Transform(AllDates, each Date.StartOfMonth(Date.From(_))),0,{[#"Grant date #(lf)(dd/mm/yyyy)"]}),each Number.From (_) >= Number.From(StDt)))
in
StofMonthDates
In the above query, Grant date means start date and Vesting end date means end date. I need to get the date as on the end date i.e., 11th March 2023 and not only the start of the month i.e., 1st March 2023

In Add Column section ,choose Custom Column and use following formula where Number.From transform your date column to its Corresponding number
={ Number.From([Start_Date])..Number.From([End_Date]) }
it generate numbers, then you should your numbers to date.

Related

Extract Month from Date Power BI

I currently have a date field with the format 01 January 2022, 04 February 2022 Etc
I am trying to create a column that pulls out the month in MMM format (JAN, FEB)
Using Month = Month('Current Week'[Created On])
This pulls the numbered date of the month (1,2)
I tried to add in format but this does not work as Month only allows 1 argument.
What else can I do to pull out the month format that I am looking for?
Try this one:
Month String =
UPPER(
FORMAT(
DATEVALUE('Current Week'[Created On]),
"mmm"
)
)

Is it possible to change the date in one cell when another cell on another sheet shows another date?

On google sheets, I have 1 sheet that has a date range selected in two cells for one year, and then on the second sheet I have a date range for the next year. I was wondering if its possible to have:
sheet1!D2 and sheet1!D3 change to match sheet2!D2 and sheet2!D3. So if I select January 2023 in sheet2!D2 it changes the date in sheet1!D2 to January 2022 and then if I select April 2023 in sheet2!D3 it changes sheet1!D3 to April 2022
Tried conditional formatting.
what you describe is called "reference" and it is possible to reference either one or multiple cells.
in sheet2!D2 if you select January 2023 then use this in sheet1!D2:
=sheet2!D2
update 1:
=REGEXEXTRACT(sheet2!D2; "\w+ ")&REGEXEXTRACT(sheet2!D2; "\d+")-1
update 2:
=DATE(YEAR(sheet2!D2)-1; MONTH(sheet2!D2); DAY(sheet2!D2))

PowerBI next month function is not rolling over a year, any advice?

I have a column called Snapshot Effective Period (next month) which is the Nextmonth([Snapshot Period]). This function stops when the snapshot period is 12/1/2021, what I expect to see is 1/1/2022 when the snapshot period is 12/1/2021. The value is not rolling over a year. Any advice?
Snapshot effective period next month c1 is a calculated column in date format.
Snapshot Effective Period (Next Month) c1 = NEXTMONTH('Forecast Detail'[Snapshot Period])
NEXTMONTH function should be used on Calendar
Notes In order to use any time intelligence calculation, you need a
well-formed date table. The Date table must satisfy the following
requirements:
All dates need to be present for the years required. The Date table
must always start on January 1 and end on December 31, including all
the days in this range. If the report only references fiscal years,
then the date table must include all the dates from the first to the
last day of a fiscal year. For example, if the fiscal year 2008 starts
on July 1, 2007, then the Date table must include all the days from
July 1, 2007 to June 30, 2008. There needs to be a column with a
DateTime or Date data type containing unique values. This column is
usually called Date. Even though the Date column is often used to
define relationships with other tables, this is not required. Still,
the Date column must contain unique values and should be referenced by
the Mark as Date Table feature. In case the column also contains a
time part, no time should be used – for example, the time should
always be 12:00 am. The Date table must be marked as a date table in
the model, in case the relationship between the Date table and any
other table is not based on the Date.
https://dax.guide/nextmonth/
Instead of NEXTMONTH use DATE
Snapshot Effective Period (Next Month) c1 = DATE( YEAR('Forecast Detail'[Snapshot Period]), MONTH('Forecast Detail'[Snapshot Period]) +1, DAY('Forecast Detail'[Snapshot Period]))

Relative date filter on calendar week not calculating last date of the latest week correctly

I have date dimension table and sales fact table.
Created a chart visual with date week on x axis and values as sum of salesamt.
In the filter pane added relative filter to the date. In the last 4 calendar weeks.
I have a measure that shows LASTDATE(DateTable[Date]) also on the report.
The last date is showing as 6 Feb 2021 (Saturday)
Same value when I select the latest week on x axis.
However when I choose any prior week on x axis, then the last date value is Sunday 31 Jan 2021.
Why does the current week last date show as 6th Jan 2021 (saturday) instead of 7th Jan 2021 (sunday)?
Currently, calendar week is defined Sunday to Saturday when it comes to filtering using relative dates. You can work around it by introducing additional column (basically date - 1 day) and set your relative filter on that.

Automatically add one year to date column when item is created

I have a date column where I want it to automatically populate with the date from today plus 1 year.
For example, if the todays date is 31 august 2020 the value of the date column will be set 31 august 2021.
What is the calculating value for the above?
=DATE(YEAR([Date])+1,MONTH([Date]),DAY([Date]))
Try this.
Here [Date] is the date Sharepoint column
https://learn.microsoft.com/en-us/previous-versions/office/developer/sharepoint-2010/bb862071(v=office.14)
The formula of calculated value should be this:
=DATE(YEAR(Today)+1,MONTH(Today),DAY(Today))