Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
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
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
114 | |
100 | |
78 | |
75 | |
52 |
User | Count |
---|---|
144 | |
109 | |
108 | |
88 | |
61 |