cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
Anonymous
Not applicable

Custom Column with addition of # of Days from Another Column

Sorry if this was asked previously I couldn't find it.  My end goal is to display the date we will run out of a material.  I basically have a column that contains today date and another column with a # of Days we have on hand.  Currently getting error expression.error The number is out of range of a 32 bit interger value.

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

Hi, @Anonymous ;

You could add custom column such as:

Date.AddDays([Date],[days])

vyalanwumsft_0-1663136214583.png

Or 

[Date]+#duration([days],0,0,0)

vyalanwumsft_1-1663136342800.png

The final show:

vyalanwumsft_2-1663136363691.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwMtQ11DVS0lEyNFCK1QGLGOka65oBRYyQRCx1gfI6SsZAoVgA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, days = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"days", Int64.Type}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each Date.AddDays([Date],[days])),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "Custom.1", each [Date]+#duration([days],0,0,0))
in
    #"Added Custom1"


Best Regards,
Community Support Team _ Yalan Wu
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-yalanwu-msft
Community Support
Community Support

Hi, @Anonymous ;

You could add custom column such as:

Date.AddDays([Date],[days])

vyalanwumsft_0-1663136214583.png

Or 

[Date]+#duration([days],0,0,0)

vyalanwumsft_1-1663136342800.png

The final show:

vyalanwumsft_2-1663136363691.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwMtQ11DVS0lEyNFCK1QGLGOka65oBRYyQRCx1gfI6SsZAoVgA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, days = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"days", Int64.Type}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each Date.AddDays([Date],[days])),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "Custom.1", each [Date]+#duration([days],0,0,0))
in
    #"Added Custom1"


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

HotChilli
Super User
Super User

I understand in basic terms what you are trying to do. Add a number of days (in a column) to a date from another column.  That's why I showed the function AddDays. 

If there is a problem with "# of days" being null or zero then show me what you have and what you want the desired result to be

Anonymous
Not applicable

Sorry I am very new user.  I tried that but the # isn't consistant.  I actually want the date column (9/13/2022) to get added to a column that has the # of days (for example, 3)  I want it to display 9/16/2022 but not every row will have contact number (like 3)

HotChilli
Super User
Super User

Are you using the Date.AddDays function?

e.g. Date.AddDays(#date(2011, 5, 14), 5)

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors