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
RafaelAri
Helper II
Helper II

Custom date in power query

Hello,

I need custome column in PQ, where I have already "Date" column.

If month is 2 (Feb.) to 11 (Nov.), result is the 1st day of previous month, same year, .

If monthe is 1 (Jan.), result is the 1st day, of month 12 (Dec.), last year.

Please help with the correct "if" query

 

1 ACCEPTED SOLUTION
manvishah17
Responsive Resident
Responsive Resident

Hi @RafaelAri ,
You can add a custom column and try this ,

 

if Date.Month([Date]) = 1 then #date(Date.Year([Date])-1, 12, 1) else #date(Date.Year([Date]), Date.Month([Date])-1, 1))

 

Screenshot 2024-07-10 115902.png

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

 

 

View solution in original post

3 REPLIES 3
Joe_Barry
Super User
Super User

Hi @RafaelAri 

 

You can try

Date.From(Date.StartOfMonth(Date.AddMonths([Date], -1)))

 

Hope this helps

Joe




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Learn about the Star Schema, it will solve many issues in Power BI!

Date tables help! Learn more



LinkedIn
Let's connect on LinkedIn


manvishah17
Responsive Resident
Responsive Resident

Hi @RafaelAri ,
You can add a custom column and try this ,

 

if Date.Month([Date]) = 1 then #date(Date.Year([Date])-1, 12, 1) else #date(Date.Year([Date]), Date.Month([Date])-1, 1))

 

Screenshot 2024-07-10 115902.png

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

 

 

Tnx a lot @manvishah17 

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.