Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
jckypatel
New Member

Change start date and End date of month

My start date of every month is 25th and end date is 24th.

 

For example - For September 2023, I need date from 25th August 2023 To 24th September 2023

 

 

Plz help me

1 ACCEPTED SOLUTION
BA_Pete
Super User
Super User

Hi @jckypatel ,

 

I'm assuming you're starting from a list of contiguous dates in a calendar table. As such, try this:

let
  Source =
  List.Transform(
    { Number.From(#date(2023,11,1))..Number.From(#date(2024,03,31)) },
    each Date.From(_)
  ),
  convToTable = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
  chgDateType = Table.TransformColumnTypes(convToTable, {{"Column1", type date}}),
  renCols = Table.RenameColumns(chgDateType, {{"Column1", "date"}}),

// Relevant step here ----->
  addMonthYear =
  Table.AddColumn(
    renCols,
    "monthYear",
    each if Date.Day([date]) >= 25
    then Text.Combine({Date.MonthName(Date.AddMonths([date], 1)), Text.From(Date.Year(Date.AddMonths([date], 1)))}, " ")
    else Text.Combine({Date.MonthName([date]), Text.From(Date.Year([date]))}, " ")
  )
  
in
  addMonthYear

 

It's only the 'addMonthYear' step you need, the rest of it is just building the date list, which you should already have.

 

Example output:

BA_Pete_0-1697448150843.png

 

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




View solution in original post

3 REPLIES 3
BA_Pete
Super User
Super User

Hi @jckypatel ,

 

I'm assuming you're starting from a list of contiguous dates in a calendar table. As such, try this:

let
  Source =
  List.Transform(
    { Number.From(#date(2023,11,1))..Number.From(#date(2024,03,31)) },
    each Date.From(_)
  ),
  convToTable = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
  chgDateType = Table.TransformColumnTypes(convToTable, {{"Column1", type date}}),
  renCols = Table.RenameColumns(chgDateType, {{"Column1", "date"}}),

// Relevant step here ----->
  addMonthYear =
  Table.AddColumn(
    renCols,
    "monthYear",
    each if Date.Day([date]) >= 25
    then Text.Combine({Date.MonthName(Date.AddMonths([date], 1)), Text.From(Date.Year(Date.AddMonths([date], 1)))}, " ")
    else Text.Combine({Date.MonthName([date]), Text.From(Date.Year([date]))}, " ")
  )
  
in
  addMonthYear

 

It's only the 'addMonthYear' step you need, the rest of it is just building the date list, which you should already have.

 

Example output:

BA_Pete_0-1697448150843.png

 

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Thanx for the help....

 

 

Also i  am adding in this.... I have to convert this Month in to Financial Year & financial Quarter. E.G April 2023 to March 2024 is my 2023-24 Financial Year & April to June is My Quarter 1.

 

 

Kindly help me.  

rubayatyasmin
Super User
Super User

Hi, @jckypatel 

 

Create a custom date table using DAX. For e.g:

 

CustomDateTable = 
ADDCOLUMNS (
    CALENDAR (DATE(Year(TODAY())-1, MONTH(TODAY())-1, 25), DATE(Year(TODAY()), MONTH(TODAY()), 24)),
    "Year", YEAR([Date]),
    "Month Number", MONTH([Date]),
    "Month Name", FORMAT([Date], "MMMM"),
    "Year-Month", FORMAT([Date], "YYYY-MMM")
)

 

Mark the date column as Date then create relationship with your desired table. 

 

rubayatyasmin_0-1689517080227.png


Did I answer your question? Mark my post as a solution!super-user-logo

Proud to be a Super User!


Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors