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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
tgarthaffner
New Member

Change ANY date to Text

Good day. 

 

I have what seems to be a simple task but I cannot figure it out.

 

I have a list of dates when a task was completed. I do not want to list the date but simply an "X" to depict that the task was accomplished. So, I want to replace or transform ANY date in a column with the letter X, this can be another column if required. Please advise.

 

Thank you. 

1 ACCEPTED SOLUTION
dufoq3
Super User
Super User

Hi @tgarthaffner, replace yellow with your previous step reference and orange with column name where you want to replace dates.

 

dufoq3_0-1709572929773.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjLVNzDUNzIwMlGK1YlW8sxTCCjKTy9KLS4G840s9A2MENIhqcUlSrGxAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
    ReplaceDatesWithX = Table.ReplaceValue(Source,
     null,
     "X",
     (x,y,z)=> if (try Date.From(x) otherwise false) is date then z else x,
     {"Column1"} )
in
    ReplaceDatesWithX

Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

View solution in original post

3 REPLIES 3
dufoq3
Super User
Super User

Hi @tgarthaffner, replace yellow with your previous step reference and orange with column name where you want to replace dates.

 

dufoq3_0-1709572929773.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjLVNzDUNzIwMlGK1YlW8sxTCCjKTy9KLS4G840s9A2MENIhqcUlSrGxAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
    ReplaceDatesWithX = Table.ReplaceValue(Source,
     null,
     "X",
     (x,y,z)=> if (try Date.From(x) otherwise false) is date then z else x,
     {"Column1"} )
in
    ReplaceDatesWithX

Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

You can also combine these two approaches, no need for a full (x,y,z)  function.  But you must specify the culture.

 

 

 

let
  Source = Table.FromRows(
    Json.Document(
      Binary.Decompress(
        Binary.FromText(
          "i45WMjLVNzDUNzIwMlGK1YlW8sxTCCjKTy9KLS4G840s9A2MENIhqcUlSrGxAA==", 
          BinaryEncoding.Base64
        ), 
        Compression.Deflate
      )
    )
  ), 
  #"Replaced Value" = Table.ReplaceValue(
    Source, 
    each [Column1], 
    each 
      if (try Value.Is(Date.From([Column1], "en-GB"), type date) otherwise false) then
        "X"
      else
        [Column1], 
    Replacer.ReplaceValue, 
    {"Column1"}
  )
in
  #"Replaced Value"

 

 

Anonymous
Not applicable

In a custom column, include

 

each if Value.Type([DateColumn]) = type date then "X" else null

 

--Nate

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 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.

Top Kudoed Authors