Forum Discussion
philerob2014
3 years agoFrequent Visitor
Timestamp when true
Hey Everyone, I need some help. Essentially, I am trying to timestamp a record once the conditions are true. If Condition 1 = true and condition 2 = true date/timestamp else leavel empt...
- 3 years ago
Hi philerob2014 ,
Maybe like this?
Before:
After:
I applied the following logic:
if [Substate] = "Pending return" and [timestamp] <> null then [timestamp] else if [Substate] = "Pending return" and [timestamp] = null then DateTime.LocalNow() else if [Substate] <> "Pending return" and [timestamp] <> null then null else null
Here the full code:
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCkjNS8nMS1coSi0pLcpT0lEyMjAy0jU00jUwUzA0sjIwACKlWJ1opbTEnOJUNHlDLPJgDoapuERjAQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Substate = _t, timestamp = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Substate", type text}, {"timestamp", type datetime}}), #"Replace Values" = Table.ReplaceValue(#"Changed Type",each [timestamp],each if [Substate] = "Pending return" and [timestamp] <> null then [timestamp] else if [Substate] = "Pending return" and [timestamp] = null then DateTime.LocalNow() else if [Substate] <> "Pending return" and [timestamp] <> null then null else null, Replacer.ReplaceValue,{"timestamp"}) in #"Replace Values"/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/
tackytechtom
3 years agoMost Valuable Professional
Hi philerob2014 ,
I reckon with timestamp you mean the current timestamp?
Here a solution in DAX with a calculated column:
timestampcol = IF ( 'Table'[column] = TRUE, NOW(), BLANK() )
I am not sure though, whether this is what you were looking for 🙂
Let me know!
/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/