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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Jimb2007
Regular Visitor

Adding Days to current date

So i have a field that shows the number of days till out of inventory and I want to have it add to the current date so I know what the date is the inventory will run out.  Then I can compare the date the inventory will run out to the date the on order items will arrive to determine if I have an inventory gap or not.  How do I do this.  Been reading a ton of message boards and can't find a way to make this work.  Please help.

1 ACCEPTED SOLUTION
watkinnc
Super User
Super User

You could add a column. Say your last step name is FinalStep, and your days on hand field is DaysOnHand:

CurrentDate= Date.From(DateTime.LocalNow()),
NewColumn = Table.AddColumn(FinalStep,  "OutOfStockDate", each Date.AddDays(CurrentDate, [DaysOnHand]))

 

This will add the amount of days from DaysOnHand to today's date.

--Nate 


I’m usually answering from my phone, which means the results are visualized only in my mind. You’ll need to use my answer to know that it works—but it will work!!

View solution in original post

4 REPLIES 4
watkinnc
Super User
Super User

You could add a column. Say your last step name is FinalStep, and your days on hand field is DaysOnHand:

CurrentDate= Date.From(DateTime.LocalNow()),
NewColumn = Table.AddColumn(FinalStep,  "OutOfStockDate", each Date.AddDays(CurrentDate, [DaysOnHand]))

 

This will add the amount of days from DaysOnHand to today's date.

--Nate 


I’m usually answering from my phone, which means the results are visualized only in my mind. You’ll need to use my answer to know that it works—but it will work!!

So I have created to column "Current Date" but when I try your recommended solution to add to that colum the number of days til out I get an error.  Seems to be with FinalStep.  I do not understand why.  Is this just to name the column or to provide a calucalated function? What is the function of FinalStep?

Jimb2007_0-1621894352206.png

 

v-angzheng-msft
Community Support
Community Support

Hi, @Jimb2007 

 

Could you please consdier sharing more details about it or a simple sample file without any sesentive information for further discussion?

 

 

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

mahoneypat
Employee
Employee

You can use TODAY() in DAX columns/measures or Date.From(DateTime.LocalNow()) in the query editor to get the current date to add to your column.  If it's a measure, you need to use the TODAY() approach.

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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