Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more
I have a policy effective date in my dataset.
I need to calculate the number of days from that date, to today. And I want to do this in Query Editor, not Dax.
I used the following formula which doesn't work, see screenshot. Changing the column type also doesn't seem to make a difference
= Table.AddColumn(PreviousStep, "Days since EffectiveDate", each (DateTime.LocalNow()-[EffectiveDate]))
Solved! Go to Solution.
Hmm, try this:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("ddFBCoQwDIXhqwxZC21SrXZ2uplDlJ5hRPD+zqID5dfuCl+SkrycxZypM6/p5d/eyyCf43vu6++hUobWFW5wgwd4gI/wET7BJ3iER/j893Cfv7X7hfv8rd3vwdeHfv7P/rl3n+pL7z7VU+8+1ZUBRhYwQV5IGeHCAmaYpJQL", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Timestamp = _t, Group = _t, RunningTotal = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Timestamp", type datetime}, {"Group", type text}, {"RunningTotal", Int64.Type}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each DateTime.LocalNow() - [Timestamp])
in
#"Added Custom"
Perhaps the issue is your time is a Date and not a Date Time?
Yeah, that's really strange, shouldn't be any different putting it into a formula versus a separate column. Weird!
Hmm, try this:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("ddFBCoQwDIXhqwxZC21SrXZ2uplDlJ5hRPD+zqID5dfuCl+SkrycxZypM6/p5d/eyyCf43vu6++hUobWFW5wgwd4gI/wET7BJ3iER/j893Cfv7X7hfv8rd3vwdeHfv7P/rl3n+pL7z7VU+8+1ZUBRhYwQV5IGeHCAmaYpJQL", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Timestamp = _t, Group = _t, RunningTotal = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Timestamp", type datetime}, {"Group", type text}, {"RunningTotal", Int64.Type}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each DateTime.LocalNow() - [Timestamp])
in
#"Added Custom"
Perhaps the issue is your time is a Date and not a Date Time?
@Greg_Deckler good point, so I tried changing [EffectiveDate] to DateTime and it made the formula even worse!
To get around this I have created a [Today] column, and then highlighted both columns > Add Column > Date > Subtract
This got me my value. I wanted to embed the [Today] in one formula though rather than create a separate column. In excel it is literally
=Sum(Today() - [@EffectiveDate])
Anyway, thank you for your suggested solution but I think mine is a little simpler (you might say cruder!)
Jemma
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.