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

Get Fabric certified for FREE! Don't miss your chance! Learn more

Reply
Gringohekus
New Member

Using Date formulas in power Query (1D, 2W, etc)

Hi, I am developing reports from Business Central where payment terms,leadtimes are defined in Date Formulas.

How can I use these formats in Power Query formulas?

 

https://docs.microsoft.com/en-us/dynamics365/business-central/ui-enter-date-ranges

 

https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/datef...

 

Thanks,

1 ACCEPTED SOLUTION

Hi @Gringohekus ,

 

You could add a custom column something like this:

Payment_Terms_Days =
if Text.Contains([Payment_Terms_Link.Due_Date_...], "W")
then Number.From(Text.Select([Payment_Terms_Link.Due_Date_...], {"0".."9"})) * 7
else Number.From(Text.Select([Payment_Terms_Link.Due_Date_...], {"0".."9"})

 

This should give you a column that converts your 30D/2W column into number of days that you can use for further date calculations. It's also easy enough to see the formula structure I've used if you wanted to add conditions for 'M' or 'Y' etc.

 

I get the following output:

BA_Pete_0-1642784891940.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

4 REPLIES 4
AlexisOlson
Super User
Super User

It would help if you could be more specific. Can you give some example inputs and expected outputs?

 

How to Get Your Question Answered Quickly

@AlexisOlson 

Sure.

I want to calculate in my query the due of each PO line based on the Requested Receipt Date of the PO Line and Payment Termformula from the PO Header:

Gringohekus_1-1642781314632.png

Obviously it is not working.

I also tried the Expression.Evaluate  formula which is used to to calculate this formula in AI language  But it also not works.

Gringohekus_2-1642781484460.png

 

 

Hi @Gringohekus ,

 

You could add a custom column something like this:

Payment_Terms_Days =
if Text.Contains([Payment_Terms_Link.Due_Date_...], "W")
then Number.From(Text.Select([Payment_Terms_Link.Due_Date_...], {"0".."9"})) * 7
else Number.From(Text.Select([Payment_Terms_Link.Due_Date_...], {"0".."9"})

 

This should give you a column that converts your 30D/2W column into number of days that you can use for further date calculations. It's also easy enough to see the formula structure I've used if you wanted to add conditions for 'M' or 'Y' etc.

 

I get the following output:

BA_Pete_0-1642784891940.png

 

Pete



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

Proud to be a Datanaut!




Power Query uses the M language whereas the links you gave in your post are related to the AL language.

 

I'm not aware of any M functions that automatically interpret these types of input so I think you'd have to define how to parse these yourself.

Helpful resources

Announcements
Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.