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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
roopa_123
Helper I
Helper I

Power Query

Hi,

How can I create a table in power query which lists only the starting day of all months until current day?
For example: my start date is 1/1/2021 and end date is currentdate, how can I create a table which lists only the starting date of the month?
I would like to achieve this using powerquery only and not DAX 🙂
Thanks in advance!

1 ACCEPTED SOLUTION
v-yiruan-msft
Community Support
Community Support

Hi @roopa_123 ,

I created a sample pbix file(see attachment) for you, please check whether that is what you want. You can apply the codes in your Advanced Editor:

let
  StDt = #date(2021, 1, 1), 
  AllDates = {Number.From(StDt) .. Number.From(Date.From(DateTime.LocalNow()))}, 
  StofMonthDates = List.Distinct(
    List.Select(
      List.InsertRange(List.Transform(AllDates, each Date.StartOfMonth(Date.From(_))), 0, {StDt}), 
      each Number.From(_) >= Number.From(StDt)
    )
  ), 
  #"Converted to Table" = Table.FromList(
    StofMonthDates, 
    Splitter.SplitByNothing(), 
    null, 
    null, 
    ExtraValues.Error
  ),
    #"Changed Type" = Table.TransformColumnTypes(#"Converted to Table",{{"Column1", type date}}),
    #"Renamed Columns" = Table.RenameColumns(#"Changed Type",{{"Column1", "Date"}})
in
  #"Renamed Columns"

yingyinr_0-1651566924082.png

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-yiruan-msft
Community Support
Community Support

Hi @roopa_123 ,

I created a sample pbix file(see attachment) for you, please check whether that is what you want. You can apply the codes in your Advanced Editor:

let
  StDt = #date(2021, 1, 1), 
  AllDates = {Number.From(StDt) .. Number.From(Date.From(DateTime.LocalNow()))}, 
  StofMonthDates = List.Distinct(
    List.Select(
      List.InsertRange(List.Transform(AllDates, each Date.StartOfMonth(Date.From(_))), 0, {StDt}), 
      each Number.From(_) >= Number.From(StDt)
    )
  ), 
  #"Converted to Table" = Table.FromList(
    StofMonthDates, 
    Splitter.SplitByNothing(), 
    null, 
    null, 
    ExtraValues.Error
  ),
    #"Changed Type" = Table.TransformColumnTypes(#"Converted to Table",{{"Column1", type date}}),
    #"Renamed Columns" = Table.RenameColumns(#"Changed Type",{{"Column1", "Date"}})
in
  #"Renamed Columns"

yingyinr_0-1651566924082.png

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-yiruan-msft : Thanks for helping out with a solution! 

truptis
Community Champion
Community Champion

Hi @roopa_123 ,

You may try this:

https://youtu.be/XQItjpSasLQ 

Hi @truptis ,
The link provided shows how to generates all the dates, but according to my requirement, I only want to generate the date for first date of every month.

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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