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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

Add a dynamic "Days of Last Month" column in Query Editor

I'm trying to add a custom column to my table that would dynamically list the days of last month.

 

Example: 

In October the table would have rows:

  • 1/9/18
  • 2/9/18
  • ...
  • 29/9/18
  • 30/9/18

 

In November:

  • 1/10/18
  • 2/10/18
  • ...
  • 30/10/18
  • 31/10/18

 

I've been drilling into the Date functions (documented here) but can't see one that would cater to this requirement.

 

Is this function possible?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

I ended up merging both queries based on the date column. After expanding the merge, filtering some blank/"null" rows, removing duplicates and filtering appropriately I was able to cobble together my solution.

View solution in original post

3 REPLIES 3
ChrisMendoza
Resident Rockstar
Resident Rockstar

@Anonymous,

 

What is the correct answer for when the previous month exceeds the current month, e.g. Nov has 30 days where Oct has 31? Also notice rows 30 & 31 where Sept 30 is repeated.

 

Did you try Date.AddMonths ( )?

 

Of course I am presuming you have a Date column with a contiguous date range.

 

Custom Column = Date.AddMonths ( [Date], -1 )

1.PNG






Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

Proud to be a Super User!



Anonymous
Not applicable

I don't currently have a column of the current month. I'm happy to add whatever else I need to make this work though.

 

Edit: I should state that I don't know of a function that just lists all of the days of the current month. I anticipate the same issue you raised for months when there are 30 vs 31 days and using a function that is (date) - 1.

 

The issue I'm trying to solve is that I have 2 sets of data, with no unique fields to create a relationship. So I was trying to create some sort of "joiner" table of data that could hold unique dates and relate those to the duplicate dates in each other table.

 

I suppose another thing I could investigate is copying a column from another table and just removing duplicates. Bit hacky but it might serve..

Anonymous
Not applicable

I ended up merging both queries based on the date column. After expanding the merge, filtering some blank/"null" rows, removing duplicates and filtering appropriately I was able to cobble together my solution.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.